annotate lisp/progmodes/cperl-mode.el @ 21636:10d8ced94467

(read1): Compute NaN and infinities using 0.0 in a variable, to cope with compilers that think they are smarter than us.
author Richard M. Stallman <rms@gnu.org>
date Fri, 17 Apr 1998 23:36:34 +0000
parents 79530a618cd3
children 0544aa57ff27
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; cperl-mode.el --- Perl code editing commands for Emacs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1985, 86, 87, 91, 92, 93, 94, 95, 96, 1997
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4 ;; Free Software Foundation, Inc.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Author: Ilya Zakharevich and Bob Olson
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7 ;; Maintainer: Ilya Zakharevich <ilya@math.ohio-state.edu>
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; Keywords: languages, Perl
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; any later version.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;;; Corrections made by Ilya Zakharevich ilya@math.mps.ohio-state.edu
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;;; XEmacs changes by Peter Arius arius@informatik.uni-erlangen.de
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;;; Commentary:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;;; You can either fine-tune the bells and whistles of this mode or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 ;;; bulk enable them by putting
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 ;; (setq cperl-hairy t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 ;;; in your .emacs file. (Emacs rulers do not consider it politically
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 ;;; correct to make whistles enabled by default.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 ;;; DO NOT FORGET to read micro-docs (available from `Perl' menu) <<<<<<
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 ;;; or as help on variables `cperl-tips', `cperl-problems', <<<<<<
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 ;;; `cperl-non-problems', `cperl-praise'. <<<<<<
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 ;;; The mode information (on C-h m) provides some customization help.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 ;;; If you use font-lock feature of this mode, it is advisable to use
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;;; either lazy-lock-mode or fast-lock-mode. I prefer lazy-lock.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 ;;; Faces used now: three faces for first-class and second-class keywords
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 ;;; and control flow words, one for each: comments, string, labels,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 ;;; functions definitions and packages, arrays, hashes, and variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;;; definitions. If you do not see all these faces, your font-lock does
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 ;;; not define them, so you need to define them manually.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 ;;; into your .emacs file.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 ;;;; This mode supports font-lock, imenu and mode-compile. In the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 ;;;; hairy version font-lock is on, but you should activate imenu
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 ;;;; yourself (note that mode-compile is not standard yet). Well, you
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 ;;;; can use imenu from keyboard anyway (M-x imenu), but it is better
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 ;;;; to bind it like that:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 ;; (define-key global-map [M-S-down-mouse-3] 'imenu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 ;;; Code:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
66 (defgroup cperl nil
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
67 "Major mode for editing Perl code."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
68 :prefix "cperl-"
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
69 :group 'languages)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
70
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 (defconst cperl-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
73 (defcustom cperl-extra-newline-before-brace nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 "*Non-nil means that if, elsif, while, until, else, for, foreach
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 and do constructs look like:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 if ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 {
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 }
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 instead of:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 if () {
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 }
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
85 "
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
86 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
87 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
88
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
89 (defcustom cperl-indent-level 2
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
90 "*Indentation of CPerl statements with respect to containing block."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
91 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
92 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
93
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
94 (defcustom cperl-lineup-step nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 "*`cperl-lineup' will always lineup at multiple of this number.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
96 If `nil', the value of `cperl-indent-level' will be used."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
97 :type '(choice (const nil) integer)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
98 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
99 (defcustom cperl-brace-imaginary-offset 0
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 "*Imagined indentation of a Perl open brace that actually follows a statement.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 An open brace following other text is treated as if it were this far
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
102 to the right of the start of its line."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
103 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
104 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
105
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
106 (defcustom cperl-brace-offset 0
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
107 "*Extra indentation for braces, compared with other text in same context."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
108 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
109 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
110 (defcustom cperl-label-offset -2
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
111 "*Offset of CPerl label lines relative to usual indentation."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
112 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
113 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
114 (defcustom cperl-min-label-indent 1
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
115 "*Minimal offset of CPerl label lines."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
116 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
117 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
118 (defcustom cperl-continued-statement-offset 2
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
119 "*Extra indent for lines not starting new statements."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
120 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
121 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
122 (defcustom cperl-continued-brace-offset 0
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 "*Extra indent for substatements that start with open-braces.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
124 This is in addition to cperl-continued-statement-offset."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
125 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
126 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
127 (defcustom cperl-close-paren-offset -1
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
128 "*Extra indent for substatements that start with close-parenthesis."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
129 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
130 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
131
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
132 (defcustom cperl-auto-newline nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 "*Non-nil means automatically newline before and after braces,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 and after colons and semicolons, inserted in CPerl code. The following
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 \\[cperl-electric-backspace] will remove the inserted whitespace.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 Insertion after colons requires both this variable and
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
137 `cperl-auto-newline-after-colon' set."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
138 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
139 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
140
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
141 (defcustom cperl-auto-newline-after-colon nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 "*Non-nil means automatically newline even after colons.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
143 Subject to `cperl-auto-newline' setting."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
144 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
145 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
146
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
147 (defcustom cperl-tab-always-indent t
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 "*Non-nil means TAB in CPerl mode should always reindent the current line,
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
149 regardless of where in the line point is when the TAB command is used."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
150 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
151 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
152
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
153 (defcustom cperl-font-lock nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 "*Non-nil (and non-null) means CPerl buffers will use font-lock-mode.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
155 Can be overwritten by `cperl-hairy' if nil."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
156 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
157 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
158
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
159 (defcustom cperl-electric-lbrace-space nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 "*Non-nil (and non-null) means { after $ in CPerl buffers should be preceded by ` '.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
161 Can be overwritten by `cperl-hairy' if nil."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
162 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
163 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
164
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
165 (defcustom cperl-electric-parens-string "({[]})<"
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 "*String of parentheses that should be electric in CPerl.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
167 Closing ones are electric only if the region is highlighted."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
168 :type 'string
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
169 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
170
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
171 (defcustom cperl-electric-parens nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 "*Non-nil (and non-null) means parentheses should be electric in CPerl.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
173 Can be overwritten by `cperl-hairy' if nil."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
174 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
175 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
176 (defcustom cperl-electric-parens-mark
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (and window-system
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (or (and (boundp 'transient-mark-mode) ; For Emacs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 transient-mark-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 (and (boundp 'zmacs-regions) ; For XEmacs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 zmacs-regions)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 "*Not-nil means that electric parens look for active mark.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
183 Default is yes if there is visual feedback on mark."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
184 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
185 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
186
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
187 (defcustom cperl-electric-linefeed nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 "*If true, LFD should be hairy in CPerl, otherwise C-c LFD is hairy.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 In any case these two mean plain and hairy linefeeds together.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
190 Can be overwritten by `cperl-hairy' if nil."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
191 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
192 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
193
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
194 (defcustom cperl-electric-keywords nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 "*Not-nil (and non-null) means keywords are electric in CPerl.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
196 Can be overwritten by `cperl-hairy' if nil."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
197 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
198 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
199
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
200 (defcustom cperl-hairy nil
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
201 "*Not-nil means all the bells and whistles are enabled in CPerl."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
202 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
203 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
204
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
205 (defcustom cperl-comment-column 32
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
206 "*Column to put comments in CPerl (use \\[cperl-indent] to lineup with code)."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
207 :type 'integer
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
208 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
209
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
210 (defcustom cperl-vc-header-alist '((SCCS "$sccs = '%W\%' ;")
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
211 (RCS "$rcs = ' $Id\$ ' ;"))
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
212 "*What to use as `vc-header-alist' in CPerl."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
213 :type '(repeat (list symbol string))
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
214 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
215
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
216 (defcustom cperl-info-on-command-no-prompt nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 "*Not-nil (and non-null) means not to prompt on C-h f.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 The opposite behaviour is always available if prefixed with C-c.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
219 Can be overwritten by `cperl-hairy' if nil."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
220 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
221 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
222
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
223 (defcustom cperl-lazy-help-time nil
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
224 "*Not-nil (and non-null) means to show lazy help after given idle time."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
225 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
226 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
227
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
228 (defcustom cperl-pod-face 'font-lock-comment-face
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
229 "*The result of evaluation of this expression is used for pod highlighting."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
230 :type 'face
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
231 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
232
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
233 (defcustom cperl-pod-head-face 'font-lock-variable-name-face
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
234 "*The result of evaluation of this expression is used for pod highlighting.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
235 Font for POD headers."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
236 :type 'face
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
237 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
238
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
239 (defcustom cperl-here-face 'font-lock-string-face
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
240 "*The result of evaluation of this expression is used for here-docs highlighting."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
241 :type 'face
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
242 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
243
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
244 (defcustom cperl-pod-here-fontify '(featurep 'font-lock)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
245 "*Not-nil after evaluation means to highlight pod and here-docs sections."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
246 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
247 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
248
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
249 (defcustom cperl-pod-here-scan t
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250 "*Not-nil means look for pod and here-docs sections during startup.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
251 You can always make lookup from menu or using \\[cperl-find-pods-heres]."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
252 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
253 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
254
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
255 (defcustom cperl-imenu-addback nil
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256 "*Not-nil means add backreferences to generated `imenu's.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
257 May require patched `imenu' and `imenu-go'."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
258 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
259 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
260
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
261 (defcustom cperl-max-help-size 66
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
262 "*Non-nil means shrink-wrapping of info-buffer allowed up to these percents."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
263 :type '(choice integer (const nil))
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
264 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
265
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
266 (defcustom cperl-shrink-wrap-info-frame t
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
267 "*Non-nil means shrink-wrapping of info-buffer-frame allowed."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
268 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
269 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
270
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
271 (defcustom cperl-info-page "perl"
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 "*Name of the info page containing perl docs.
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
273 Older version of this page was called `perl5', newer `perl'."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
274 :type 'string
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
275 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
276
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
277 (defcustom cperl-use-syntax-table-text-property
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 (boundp 'parse-sexp-lookup-properties)
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
279 "*Non-nil means CPerl sets up and uses `syntax-table' text property."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
280 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
281 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
282
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
283 (defcustom cperl-use-syntax-table-text-property-for-tags
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 cperl-use-syntax-table-text-property
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
285 "*Non-nil means: set up and use `syntax-table' text property generating TAGS."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
286 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
287 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
288
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
289 (defcustom cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\)$"
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
290 "*Regexp to match files to scan when generating TAGS."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
291 :type 'regexp
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
292 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
293
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
294 (defcustom cperl-noscan-files-regexp "/\\(\\.\\.?\\|SCCS\\|RCS\\|blib\\)$"
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
295 "*Regexp to match files/dirs to skip when generating TAGS."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
296 :type 'regexp
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
297 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
298
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
299 (defcustom cperl-regexp-indent-step nil
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
300 "*Indentation used when beautifying regexps.
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
301 If `nil', the value of `cperl-indent-level' will be used."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
302 :type '(choice integer (const nil))
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
303 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
304
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
305 (defcustom cperl-indent-left-aligned-comments t
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
306 "*Non-nil means that the comment starting in leftmost column should indent."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
307 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
308 :group 'cperl)
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
309
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
310 (defcustom cperl-under-as-char t
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
311 "*Non-nil means that the _ (underline) should be treated as word char."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
312 :type 'boolean
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
313 :group 'cperl)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 ;;; Short extra-docs.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 (defvar cperl-tips 'please-ignore-this-line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 "Get newest version of this package from
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 and/or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 Get support packages choose-color.el (or font-lock-extra.el before
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 19.30), imenu-go.el from the same place. \(Look for other files there
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 too... ;-). Get a patch for imenu.el in 19.29. Note that for 19.30 and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 later you should use choose-color.el *instead* of font-lock-extra.el
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 \(and you will not get smart highlighting in C :-().
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 Note that to enable Compile choices in the menu you need to install
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 mode-compile.el.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
334 Get perl5-info from
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335 $CPAN/doc/manual/info/perl-info.tar.gz
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 older version was on
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 http://www.metronet.com:70/9/perlinfo/perl5/manual/perl5-info.tar.gz
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 If you use imenu-go, run imenu on perl5-info buffer (you can do it
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 from CPerl menu). If many files are related, generate TAGS files from
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 Tools/Tags submenu in CPerl menu.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 If some class structure is too complicated, use Tools/Hierarchy-view
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 from CPerl menu, or hierarchic view of imenu. The second one uses the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 current buffer only, the first one requires generation of TAGS from
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 CPerl/Tools/Tags menu beforehand.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 Run CPerl/Tools/Insert-spaces-if-needed to fix your lazy typing.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 Switch auto-help on/off with CPerl/Tools/Auto-help.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 Before reporting (non-)problems look in the problem section on what I
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 know about them.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 (defvar cperl-problems 'please-ignore-this-line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 "Emacs has a _very_ restricted syntax parsing engine.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 It may be corrected on the level of C code, please look in the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 `non-problems' section if you want to volunteer.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 CPerl mode tries to corrects some Emacs misunderstandings, however,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 for efficiency reasons the degree of correction is different for
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 different operations. The partially corrected problems are: POD
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 sections, here-documents, regexps. The operations are: highlighting,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 indentation, electric keywords, electric braces.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 This may be confusing, since the regexp s#//#/#\; may be highlighted
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 as a comment, but it will be recognized as a regexp by the indentation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 code. Or the opposite case, when a pod section is highlighted, but
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 may break the indentation of the following code (though indentation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 should work if the balance of delimiters is not broken by POD).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 The main trick (to make $ a \"backslash\") makes constructions like
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374 ${aaa} look like unbalanced braces. The only trick I can think of is
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 to insert it as $ {aaa} (legal in perl5, not in perl4).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 Similar problems arise in regexps, when /(\\s|$)/ should be rewritten
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 as /($|\\s)/. Note that such a transposition is not always possible
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 :-(. " )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381 (defvar cperl-non-problems 'please-ignore-this-line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 "As you know from `problems' section, Perl syntax is too hard for CPerl.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384 Most the time, if you write your own code, you may find an equivalent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 \(and almost as readable) expression.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387 Try to help CPerl: add comments with embedded quotes to fix CPerl
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 misunderstandings about the end of quotation:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 $a='500$'; # ';
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 You won't need it too often. The reason: $ \"quotes\" the following
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 character (this saves a life a lot of times in CPerl), thus due to
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 Emacs parsing rules it does not consider tick (i.e., ' ) after a
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 dollar as a closing one, but as a usual character.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 Now the indentation code is pretty wise. The only drawback is that it
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 relies on Emacs parsing to find matching parentheses. And Emacs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 *cannot* match parentheses in Perl 100% correctly. So
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 1 if s#//#/#;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 will not break indentation, but
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 1 if ( s#//#/# );
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 will.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
405 By similar reasons
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 s\"abc\"def\";
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407 will confuse CPerl a lot.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409 If you still get wrong indentation in situation that you think the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 code should be able to parse, try:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
412 a) Check what Emacs thinks about balance of your parentheses.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 b) Supply the code to me (IZ).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 Pods are treated _very_ rudimentally. Here-documents are not treated
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 at all (except highlighting and inhibiting indentation). (This may
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 change some time. RMS approved making syntax lookup recognize text
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 attributes, but volunteers are needed to change Emacs C code.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 To speed up coloring the following compromises exist:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 a) sub in $mypackage::sub may be highlighted.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 b) -z in [a-z] may be highlighted.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423 c) if your regexp contains a keyword (like \"s\"), it may be highlighted.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 Imenu in 19.31 is broken. Set `imenu-use-keymap-menu' to t, and remove
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 `car' before `imenu-choose-buffer-index' in `imenu'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
428 ")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 (defvar cperl-praise 'please-ignore-this-line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
431 "RMS asked me to list good things about CPerl. Here they go:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
432
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
433 0) It uses the newest `syntax-table' property ;-);
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 1) It does 99% of Perl syntax correct (as opposed to 80-90% in Perl
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 mode - but the latter number may have improved too in last years) even
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 without `syntax-table' property; When using this property, it should
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438 handle 99.995% of lines correct - or somesuch.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
440 2) It is generally belived to be \"the most user-friendly Emacs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441 package\" whatever it may mean (I doubt that the people who say similar
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442 things tried _all_ the rest of Emacs ;-), but this was not a lonely
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 voice);
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
445 3) Everything is customizable, one-by-one or in a big sweep;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 4) It has many easily-accessable \"tools\":
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 a) Can run program, check syntax, start debugger;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449 b) Can lineup vertically \"middles\" of rows, like `=' in
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 a = b;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
451 cc = d;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
452 c) Can insert spaces where this impoves readability (in one
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
453 interactive sweep over the buffer);
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 d) Has support for imenu, including:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455 1) Separate unordered list of \"interesting places\";
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 2) Separate TOC of POD sections;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
457 3) Separate list of packages;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
458 4) Hierarchical view of methods in (sub)packages;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 5) and functions (by the full name - with package);
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 e) Has an interface to INFO docs for Perl; The interface is
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 very flexible, including shrink-wrapping of
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 documentation buffer/frame;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 f) Has a builtin list of one-line explanations for perl constructs.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
464 g) Can show these explanations if you stay long enough at the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465 corresponding place (or on demand);
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 h) Has an enhanced fontification (using 3 or 4 additional faces
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467 comparing to font-lock - basically, different
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 namespaces in Perl have different colors);
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 i) Can construct TAGS basing on its knowledge of Perl syntax,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470 the standard menu has 6 different way to generate
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 TAGS (if by directory, .xs files - with C-language
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472 bindings - are included in the scan);
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 j) Can build a hierarchical view of classes (via imenu) basing
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474 on generated TAGS file;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 k) Has electric parentheses, electric newlines, uses Abbrev
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 for electric logical constructs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 while () {}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 with different styles of expansion (context sensitive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 to be not so bothering). Electric parentheses behave
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480 \"as they should\" in a presence of a visible region.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481 l) Changes msb.el \"on the fly\" to insert a group \"Perl files\";
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 5) The indentation engine was very smart, but most of tricks may be
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484 not needed anymore with the support for `syntax-table' property. Has
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485 progress indicator for indentation (with `imenu' loaded).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
487 6) Indent-region improves inline-comments as well;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 7) Fill-paragraph correctly handles multi-line comments;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490 ")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
493
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
494 ;;; Portability stuff:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
495
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 (defmacro cperl-define-key (emacs-key definition &optional xemacs-key)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
497 (` (define-key cperl-mode-map
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
498 (, (if xemacs-key
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499 (` (if cperl-xemacs-p (, xemacs-key) (, emacs-key)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 emacs-key))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 (, definition))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 (defvar cperl-del-back-ch
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 (car (append (where-is-internal 'delete-backward-char)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505 (where-is-internal 'backward-delete-char-untabify)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
506 "Character generated by key bound to delete-backward-char.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
507
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
508 (and (vectorp cperl-del-back-ch) (= (length cperl-del-back-ch) 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
509 (setq cperl-del-back-ch (aref cperl-del-back-ch 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 (if cperl-xemacs-p
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 ;; "Active regions" are on: use region only if active
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 ;; "Active regions" are off: use region unconditionally
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 (defun cperl-use-region-p ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 (if zmacs-regions (mark) t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 (defun cperl-mark-active () (mark)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518 (defun cperl-use-region-p ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519 (if transient-mark-mode mark-active t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 (defun cperl-mark-active () mark-active))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 (defsubst cperl-enable-font-lock ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523 (or cperl-xemacs-p window-system))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525 (if (boundp 'unread-command-events)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 (if cperl-xemacs-p
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
527 (defun cperl-putback-char (c) ; XEmacs >= 19.12
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 (setq unread-command-events (list (character-to-event c))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 (defun cperl-putback-char (c) ; Emacs 19
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 (setq unread-command-events (list c))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
531 (defun cperl-putback-char (c) ; XEmacs <= 19.11
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 (setq unread-command-event (character-to-event c))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 (or (fboundp 'uncomment-region)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 (defun uncomment-region (beg end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 (interactive "r")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 (comment-region beg end -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 (defvar cperl-do-not-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
540 (if (string< emacs-version "19.30")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
541 'fontified
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 'lazy-lock)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
543 "Text property which inhibits refontification.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545 (defsubst cperl-put-do-not-fontify (from to)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546 (put-text-property (max (point-min) (1- from))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 to cperl-do-not-fontify t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
549 (defcustom cperl-mode-hook nil
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
550 "Hook run by `cperl-mode'."
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
551 :type 'hook
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
552 :group 'cperl)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
555 ;;; Probably it is too late to set these guys already, but it can help later:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557 ;;;(setq auto-mode-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 ;;; (append '(("\\.\\([pP][Llm]\\|al\\)$" . perl-mode)) auto-mode-alist ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559 ;;;(and (boundp 'interpreter-mode-alist)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560 ;;; (setq interpreter-mode-alist (append interpreter-mode-alist
20961
79530a618cd3 Commented out line 471 (miniperl entry in interpreter-mode-alist)
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
561 ;;; '(("miniperl" . perl-mode)))))
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562 (if (fboundp 'eval-when-compile)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563 (eval-when-compile
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
564 (condition-case nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565 (require 'imenu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 (error nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567 (condition-case nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 (require 'easymenu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569 (error nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
570 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571 ;; macros instead of defsubsts don't work on Emacs, so we do the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 ;; expansion manually. Any other suggestions?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573 (if (or (string-match "XEmacs\\|Lucid" emacs-version)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
574 window-system)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
575 (require 'font-lock))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 (require 'cl)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577 ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
579 (defvar cperl-mode-abbrev-table nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 "Abbrev table in use in Cperl-mode buffers.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582 (add-hook 'edit-var-mode-alist '(perl-mode (regexp . "^cperl-")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
583
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 (defvar cperl-mode-map () "Keymap used in CPerl mode.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 (if cperl-mode-map nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587 (setq cperl-mode-map (make-sparse-keymap))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 (cperl-define-key "{" 'cperl-electric-lbrace)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
589 (cperl-define-key "[" 'cperl-electric-paren)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
590 (cperl-define-key "(" 'cperl-electric-paren)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 (cperl-define-key "<" 'cperl-electric-paren)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592 (cperl-define-key "}" 'cperl-electric-brace)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593 (cperl-define-key "]" 'cperl-electric-rparen)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594 (cperl-define-key ")" 'cperl-electric-rparen)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 (cperl-define-key ";" 'cperl-electric-semi)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596 (cperl-define-key ":" 'cperl-electric-terminator)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 (cperl-define-key "\C-j" 'newline-and-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 (cperl-define-key "\C-c\C-j" 'cperl-linefeed)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 (cperl-define-key "\C-c\C-a" 'cperl-toggle-auto-newline)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600 (cperl-define-key "\C-c\C-k" 'cperl-toggle-abbrev)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601 (cperl-define-key "\C-c\C-e" 'cperl-toggle-electric)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 (cperl-define-key "\e\C-q" 'cperl-indent-exp) ; Usually not bound
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603 (cperl-define-key [?\C-\M-\|] 'cperl-lineup
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 [(control meta |)])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605 ;;(cperl-define-key "\M-q" 'cperl-fill-paragraph)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 ;;(cperl-define-key "\e;" 'cperl-indent-for-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
607 (cperl-define-key "\177" 'cperl-electric-backspace)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608 (cperl-define-key "\t" 'cperl-indent-command)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609 ;; don't clobber the backspace binding:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 (cperl-define-key "\C-c\C-hf" 'cperl-info-on-current-command
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611 [(control c) (control h) f])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 (cperl-define-key "\C-hf"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 ;;(concat (char-to-string help-char) "f") ; does not work
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 'cperl-info-on-command
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 [(control h) f])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616 (cperl-define-key "\C-hv"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617 ;;(concat (char-to-string help-char) "v") ; does not work
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 'cperl-get-help
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
619 [(control h) v])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620 (if (and cperl-xemacs-p
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 (<= emacs-minor-version 11) (<= emacs-major-version 19))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623 ;; substitute-key-definition is usefulness-deenhanced...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 (cperl-define-key "\M-q" 'cperl-fill-paragraph)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
625 (cperl-define-key "\e;" 'cperl-indent-for-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 (cperl-define-key "\e\C-\\" 'cperl-indent-region))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 (substitute-key-definition
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628 'indent-sexp 'cperl-indent-exp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 cperl-mode-map global-map)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
630 (substitute-key-definition
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631 'fill-paragraph 'cperl-fill-paragraph
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
632 cperl-mode-map global-map)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
633 (substitute-key-definition
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
634 'indent-region 'cperl-indent-region
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635 cperl-mode-map global-map)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 (substitute-key-definition
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 'indent-for-comment 'cperl-indent-for-comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638 cperl-mode-map global-map)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640 (defvar cperl-menu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641 (condition-case nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643 (require 'easymenu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 (easy-menu-define cperl-menu cperl-mode-map "Menu for CPerl mode"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
645 '("Perl"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 ["Beginning of function" beginning-of-defun t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 ["End of function" end-of-defun t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 ["Mark function" mark-defun t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649 ["Indent expression" cperl-indent-exp t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 ["Fill paragraph/comment" cperl-fill-paragraph t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651 "----"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 ["Line up a construction" cperl-lineup (cperl-use-region-p)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 ["Beautify a regexp" cperl-beautify-regexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 cperl-use-syntax-table-text-property]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 ["Beautify a group in regexp" cperl-beautify-level
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 cperl-use-syntax-table-text-property]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 ["Contract a group in regexp" cperl-contract-level
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 cperl-use-syntax-table-text-property]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659 ["Refresh \"hard\" constructions" cperl-find-pods-heres t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 "----"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
661 ["Indent region" cperl-indent-region (cperl-use-region-p)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
662 ["Comment region" cperl-comment-region (cperl-use-region-p)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
663 ["Uncomment region" cperl-uncomment-region (cperl-use-region-p)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
664 "----"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
665 ["Run" mode-compile (fboundp 'mode-compile)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
666 ["Kill" mode-compile-kill (and (fboundp 'mode-compile-kill)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
667 (get-buffer "*compilation*"))]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668 ["Next error" next-error (get-buffer "*compilation*")]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
669 ["Check syntax" cperl-check-syntax (fboundp 'mode-compile)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670 "----"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
671 ["Debugger" cperl-db t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672 "----"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 ("Tools"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674 ["Imenu" imenu (fboundp 'imenu)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 ["Insert spaces if needed" cperl-find-bad-style t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 ["Class Hierarchy from TAGS" cperl-tags-hier-init t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 ;;["Update classes" (cperl-tags-hier-init t) tags-table-list]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678 ["Imenu on info" cperl-imenu-on-info (featurep 'imenu)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 ("Tags"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 ;;; ["Create tags for current file" cperl-etags t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 ;;; ["Add tags for current file" (cperl-etags t) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 ;;; ["Create tags for Perl files in directory" (cperl-etags nil t) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 ;;; ["Add tags for Perl files in directory" (cperl-etags t t) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
684 ;;; ["Create tags for Perl files in (sub)directories"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
685 ;;; (cperl-etags nil 'recursive) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
686 ;;; ["Add tags for Perl files in (sub)directories"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 ;;; (cperl-etags t 'recursive) t])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688 ;;;; cperl-write-tags (&optional file erase recurse dir inbuffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 ["Create tags for current file" (cperl-write-tags nil t) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 ["Add tags for current file" (cperl-write-tags) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 ["Create tags for Perl files in directory"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 (cperl-write-tags nil t nil t) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 ["Add tags for Perl files in directory"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 (cperl-write-tags nil nil nil t) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 ["Create tags for Perl files in (sub)directories"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 (cperl-write-tags nil t t t) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 ["Add tags for Perl files in (sub)directories"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 (cperl-write-tags nil nil t t) t])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 ["Define word at point" imenu-go-find-at-position
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 (fboundp 'imenu-go-find-at-position)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701 ["Help on function" cperl-info-on-command t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 ["Help on function at point" cperl-info-on-current-command t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 ["Help on symbol at point" cperl-get-help t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 ["Auto-help on" cperl-lazy-install (fboundp 'run-with-idle-timer)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705 ["Auto-help off" cperl-lazy-unstall
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 (fboundp 'run-with-idle-timer)])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 ("Toggle..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708 ["Auto newline" cperl-toggle-auto-newline t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 ["Electric parens" cperl-toggle-electric t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 ["Electric keywords" cperl-toggle-abbrev t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712 ("Indent styles..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713 ["GNU" (cperl-set-style "GNU") t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 ["C++" (cperl-set-style "C++") t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715 ["FSF" (cperl-set-style "FSF") t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 ["BSD" (cperl-set-style "BSD") t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717 ["Whitesmith" (cperl-set-style "Whitesmith") t])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
718 ("Micro-docs"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
719 ["Tips" (describe-variable 'cperl-tips) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
720 ["Problems" (describe-variable 'cperl-problems) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721 ["Non-problems" (describe-variable 'cperl-non-problems) t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722 ["Praise" (describe-variable 'cperl-praise) t]))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723 (error nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
725 (autoload 'c-macro-expand "cmacexp"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
726 "Display the result of expanding all C macros occurring in the region.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
727 The expansion is entirely correct because it uses the C preprocessor."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
728 t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
729
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
730 (defvar cperl-mode-syntax-table nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
731 "Syntax table in use in Cperl-mode buffers.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
732
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
733 (defvar cperl-string-syntax-table nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
734 "Syntax table in use in Cperl-mode string-like chunks.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
735
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
736 (if cperl-mode-syntax-table
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
737 ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
738 (setq cperl-mode-syntax-table (make-syntax-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739 (modify-syntax-entry ?\\ "\\" cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
740 (modify-syntax-entry ?/ "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741 (modify-syntax-entry ?* "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
742 (modify-syntax-entry ?+ "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
743 (modify-syntax-entry ?- "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
744 (modify-syntax-entry ?= "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745 (modify-syntax-entry ?% "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
746 (modify-syntax-entry ?< "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 (modify-syntax-entry ?> "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
748 (modify-syntax-entry ?& "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
749 (modify-syntax-entry ?$ "\\" cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750 (modify-syntax-entry ?\n ">" cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751 (modify-syntax-entry ?# "<" cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
752 (modify-syntax-entry ?' "\"" cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753 (modify-syntax-entry ?` "\"" cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
754 (if cperl-under-as-char
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755 (modify-syntax-entry ?_ "w" cperl-mode-syntax-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756 (modify-syntax-entry ?: "_" cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
757 (modify-syntax-entry ?| "." cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
758 (setq cperl-string-syntax-table (copy-syntax-table cperl-mode-syntax-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 (modify-syntax-entry ?$ "." cperl-string-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760 (modify-syntax-entry ?# "." cperl-string-syntax-table) ; (?# comment )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
763
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
764
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765 ;; Make customization possible "in reverse"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
766 ;;(defun cperl-set (symbol to)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
767 ;; (or (eq (symbol-value symbol) 'null) (set symbol to)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
768 (defsubst cperl-val (symbol &optional default hairy)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
769 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
770 ((eq (symbol-value symbol) 'null) default)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
771 (cperl-hairy (or hairy t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
772 (t (symbol-value symbol))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
773
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
774 ;; provide an alias for working with emacs 19. the perl-mode that comes
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
775 ;; with it is really bad, and this lets us seamlessly replace it.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
776 ;;;###autoload
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
777 (fset 'perl-mode 'cperl-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
778 (defvar cperl-faces-init)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
779 ;; Fix for msb.el
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
780 (defvar cperl-msb-fixed nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
781 ;;;###autoload
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
782 (defun cperl-mode ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
783 "Major mode for editing Perl code.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
784 Expression and list commands understand all C brackets.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
785 Tab indents for Perl code.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
786 Paragraphs are separated by blank lines only.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
787 Delete converts tabs to spaces as it moves back.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
788
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
789 Various characters in Perl almost always come in pairs: {}, (), [],
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
790 sometimes <>. When the user types the first, she gets the second as
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
791 well, with optional special formatting done on {}. (Disabled by
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
792 default.) You can always quote (with \\[quoted-insert]) the left
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
793 \"paren\" to avoid the expansion. The processing of < is special,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
794 since most the time you mean \"less\". Cperl mode tries to guess
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
795 whether you want to type pair <>, and inserts is if it
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
796 appropriate. You can set `cperl-electric-parens-string' to the string that
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
797 contains the parenths from the above list you want to be electrical.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
798 Electricity of parenths is controlled by `cperl-electric-parens'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
799 You may also set `cperl-electric-parens-mark' to have electric parens
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
800 look for active mark and \"embrace\" a region if possible.'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
801
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
802 CPerl mode provides expansion of the Perl control constructs:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
803 if, else, elsif, unless, while, until, for, and foreach.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
804 =========(Disabled by default, see `cperl-electric-keywords'.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
805 The user types the keyword immediately followed by a space, which causes
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
806 the construct to be expanded, and the user is positioned where she is most
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
807 likely to want to be.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
808 eg. when the user types a space following \"if\" the following appears in
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
809 the buffer:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
810 if () { or if ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
811 } {
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
812 }
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
813 and the cursor is between the parentheses. The user can then type some
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
814 boolean expression within the parens. Having done that, typing
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
815 \\[cperl-linefeed] places you, appropriately indented on a new line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
816 between the braces. If CPerl decides that you want to insert
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
817 \"English\" style construct like
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
818 bite if angry;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
819 it will not do any expansion. See also help on variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 `cperl-extra-newline-before-brace'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
822 \\[cperl-linefeed] is a convenience replacement for typing carriage
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823 return. It places you in the next line with proper indentation, or if
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
824 you type it inside the inline block of control construct, like
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
825 foreach (@lines) {print; print}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
826 and you are on a boundary of a statement inside braces, it will
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
827 transform the construct into a multiline and will place you into an
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
828 appropriately indented blank line. If you need a usual
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
829 `newline-and-indent' behaviour, it is on \\[newline-and-indent],
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
830 see documentation on `cperl-electric-linefeed'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
831
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832 \\{cperl-mode-map}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
834 Setting the variable `cperl-font-lock' to t switches on
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
835 font-lock-mode, `cperl-electric-lbrace-space' to t switches on
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
836 electric space between $ and {, `cperl-electric-parens-string' is the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
837 string that contains parentheses that should be electric in CPerl (see
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838 also `cperl-electric-parens-mark' and `cperl-electric-parens'),
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
839 setting `cperl-electric-keywords' enables electric expansion of
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
840 control structures in CPerl. `cperl-electric-linefeed' governs which
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
841 one of two linefeed behavior is preferable. You can enable all these
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
842 options simultaneously (recommended mode of use) by setting
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
843 `cperl-hairy' to t. In this case you can switch separate options off
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
844 by setting them to `null'. Note that one may undo the extra whitespace
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
845 inserted by semis and braces in `auto-newline'-mode by consequent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
846 \\[cperl-electric-backspace].
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
847
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
848 If your site has perl5 documentation in info format, you can use commands
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849 \\[cperl-info-on-current-command] and \\[cperl-info-on-command] to access it.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850 These keys run commands `cperl-info-on-current-command' and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
851 `cperl-info-on-command', which one is which is controlled by variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
852 `cperl-info-on-command-no-prompt' (in turn affected by `cperl-hairy').
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
853
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
854 Even if you have no info-format documentation, short one-liner-style
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
855 help is available on \\[cperl-get-help].
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
856
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
857 It is possible to show this help automatically after some idle
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
858 time. This is regulated by variable `cperl-lazy-help-time'. Default
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
859 with `cperl-hairy' is 5 secs idle time if the value of this variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
860 is nil. It is also possible to switch this on/off from the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
861 menu. Requires `run-with-idle-timer'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
862
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
863 Use \\[cperl-lineup] to vertically lineup some construction - put the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
864 beginning of the region at the start of construction, and make region
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
865 span the needed amount of lines.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
866
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
867 Variables `cperl-pod-here-scan', `cperl-pod-here-fontify',
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
868 `cperl-pod-face', `cperl-pod-head-face' control processing of pod and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
869 here-docs sections. In a future version results of scan may be used
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
870 for indentation too, currently they are used for highlighting only.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
871
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
872 Variables controlling indentation style:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
873 `cperl-tab-always-indent'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
874 Non-nil means TAB in CPerl mode should always reindent the current line,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
875 regardless of where in the line point is when the TAB command is used.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
876 `cperl-auto-newline'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
877 Non-nil means automatically newline before and after braces,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
878 and after colons and semicolons, inserted in Perl code. The following
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
879 \\[cperl-electric-backspace] will remove the inserted whitespace.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
880 Insertion after colons requires both this variable and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
881 `cperl-auto-newline-after-colon' set.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
882 `cperl-auto-newline-after-colon'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
883 Non-nil means automatically newline even after colons.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
884 Subject to `cperl-auto-newline' setting.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
885 `cperl-indent-level'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
886 Indentation of Perl statements within surrounding block.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
887 The surrounding block's indentation is the indentation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
888 of the line on which the open-brace appears.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
889 `cperl-continued-statement-offset'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
890 Extra indentation given to a substatement, such as the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
891 then-clause of an if, or body of a while, or just a statement continuation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
892 `cperl-continued-brace-offset'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
893 Extra indentation given to a brace that starts a substatement.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
894 This is in addition to `cperl-continued-statement-offset'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
895 `cperl-brace-offset'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
896 Extra indentation for line if it starts with an open brace.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
897 `cperl-brace-imaginary-offset'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
898 An open brace following other text is treated as if it the line started
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
899 this far to the right of the actual line indentation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
900 `cperl-label-offset'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
901 Extra indentation for line that is a label.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
902 `cperl-min-label-indent'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
903 Minimal indentation for line that is a label.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
904
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
905 Settings for K&R and BSD indentation styles are
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
906 `cperl-indent-level' 5 8
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
907 `cperl-continued-statement-offset' 5 8
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
908 `cperl-brace-offset' -5 -8
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
909 `cperl-label-offset' -5 -8
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
910
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
911 If `cperl-indent-level' is 0, the statement after opening brace in column 0 is indented on `cperl-brace-offset'+`cperl-continued-statement-offset'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
912
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
913 Turning on CPerl mode calls the hooks in the variable `cperl-mode-hook'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
914 with no args."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
915 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
916 (kill-all-local-variables)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
917 ;;(if cperl-hairy
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
918 ;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
919 ;; (cperl-set 'cperl-font-lock cperl-hairy)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
920 ;; (cperl-set 'cperl-electric-lbrace-space cperl-hairy)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
921 ;; (cperl-set 'cperl-electric-parens "{[(<")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
922 ;; (cperl-set 'cperl-electric-keywords cperl-hairy)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
923 ;; (cperl-set 'cperl-electric-linefeed cperl-hairy)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
924 (use-local-map cperl-mode-map)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
925 (if (cperl-val 'cperl-electric-linefeed)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
926 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 (local-set-key "\C-J" 'cperl-linefeed)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
928 (local-set-key "\C-C\C-J" 'newline-and-indent)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
929 (if (cperl-val 'cperl-info-on-command-no-prompt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
931 ;; don't clobber the backspace binding:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
932 (cperl-define-key "\C-hf" 'cperl-info-on-current-command [(control h) f])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
933 (cperl-define-key "\C-c\C-hf" 'cperl-info-on-command
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
934 [(control c) (control h) f])))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
935 (setq major-mode 'perl-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
936 (setq mode-name "CPerl")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
937 (if (not cperl-mode-abbrev-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
938 (let ((prev-a-c abbrevs-changed))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939 (define-abbrev-table 'cperl-mode-abbrev-table '(
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
940 ("if" "if" cperl-electric-keyword 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
941 ("elsif" "elsif" cperl-electric-keyword 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
942 ("while" "while" cperl-electric-keyword 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
943 ("until" "until" cperl-electric-keyword 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
944 ("unless" "unless" cperl-electric-keyword 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
945 ("else" "else" cperl-electric-else 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
946 ("for" "for" cperl-electric-keyword 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
947 ("foreach" "foreach" cperl-electric-keyword 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
948 ("do" "do" cperl-electric-keyword 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
949 (setq abbrevs-changed prev-a-c)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
950 (setq local-abbrev-table cperl-mode-abbrev-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
951 (abbrev-mode (if (cperl-val 'cperl-electric-keywords) 1 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
952 (set-syntax-table cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
953 (make-local-variable 'paragraph-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
954 (setq paragraph-start (concat "^$\\|" page-delimiter))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
955 (make-local-variable 'paragraph-separate)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
956 (setq paragraph-separate paragraph-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 (make-local-variable 'paragraph-ignore-fill-prefix)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958 (setq paragraph-ignore-fill-prefix t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 (make-local-variable 'indent-line-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
960 (setq indent-line-function 'cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961 (make-local-variable 'require-final-newline)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
962 (setq require-final-newline t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
963 (make-local-variable 'comment-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
964 (setq comment-start "# ")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
965 (make-local-variable 'comment-end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966 (setq comment-end "")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
967 (make-local-variable 'comment-column)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
968 (setq comment-column cperl-comment-column)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
969 (make-local-variable 'comment-start-skip)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
970 (setq comment-start-skip "#+ *")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
971 (make-local-variable 'defun-prompt-regexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
972 (setq defun-prompt-regexp "^[ \t]*sub[ \t]+\\([^ \t\n{(;]+\\)[ \t]*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
973 (make-local-variable 'comment-indent-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
974 (setq comment-indent-function 'cperl-comment-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
975 (make-local-variable 'parse-sexp-ignore-comments)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
976 (setq parse-sexp-ignore-comments t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
977 (make-local-variable 'indent-region-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
978 (setq indent-region-function 'cperl-indent-region)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
979 ;;(setq auto-fill-function 'cperl-do-auto-fill) ; Need to switch on and off!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
980 (make-local-variable 'imenu-create-index-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
981 (setq imenu-create-index-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
982 (function imenu-example--create-perl-index))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
983 (make-local-variable 'imenu-sort-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
984 (setq imenu-sort-function nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
985 (make-local-variable 'vc-header-alist)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
986 (setq vc-header-alist cperl-vc-header-alist)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
987 (make-local-variable 'font-lock-defaults)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
988 (setq font-lock-defaults
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
989 (if (string< emacs-version "19.30")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
990 '(perl-font-lock-keywords-2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
991 '((perl-font-lock-keywords
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
992 perl-font-lock-keywords-1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
993 perl-font-lock-keywords-2))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
994 (if cperl-use-syntax-table-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
995 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
996 (make-variable-buffer-local 'parse-sexp-lookup-properties)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
997 ;; Do not introduce variable if not needed, we check it!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
998 (set 'parse-sexp-lookup-properties t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
999 (or (fboundp 'cperl-old-auto-fill-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1000 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1001 (fset 'cperl-old-auto-fill-mode (symbol-function 'auto-fill-mode))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1002 (defun auto-fill-mode (&optional arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1003 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1004 (cperl-old-auto-fill-mode arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1005 (and auto-fill-function (eq major-mode 'perl-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1006 (setq auto-fill-function 'cperl-do-auto-fill)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1007 (if (cperl-enable-font-lock)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1008 (if (cperl-val 'cperl-font-lock)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1009 (progn (or cperl-faces-init (cperl-init-faces))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1010 (font-lock-mode 1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1011 (and (boundp 'msb-menu-cond)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1012 (not cperl-msb-fixed)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1013 (cperl-msb-fix))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1014 (if (featurep 'easymenu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1015 (easy-menu-add cperl-menu)) ; A NOP in Emacs.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1016 (run-hooks 'cperl-mode-hook)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1017 ;; After hooks since fontification will break this
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1018 (if cperl-pod-here-scan (cperl-find-pods-heres)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1019
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1020 ;; Fix for perldb - make default reasonable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1021 (defun cperl-db ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1022 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1023 (require 'gud)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1024 (perldb (read-from-minibuffer "Run perldb (like this): "
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1025 (if (consp gud-perldb-history)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1026 (car gud-perldb-history)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1027 (concat "perl " ;;(file-name-nondirectory
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1028 ;; I have problems
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1029 ;; in OS/2
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1030 ;; otherwise
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1031 (buffer-file-name)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1032 nil nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1033 '(gud-perldb-history . 1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1034
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1035
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1036 (defun cperl-msb-fix ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1037 ;; Adds perl files to msb menu, supposes that msb is already loaded
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1038 (setq cperl-msb-fixed t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1039 (let* ((l (length msb-menu-cond))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1040 (last (nth (1- l) msb-menu-cond))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1041 (precdr (nthcdr (- l 2) msb-menu-cond)) ; cdr of this is last
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1042 (handle (1- (nth 1 last))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1043 (setcdr precdr (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1044 (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1045 '(eq major-mode 'perl-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1046 handle
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1047 "Perl Files (%d)")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1048 last))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1049
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1050 ;; This is used by indent-for-comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1051 ;; to decide how much to indent a comment in CPerl code
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1052 ;; based on its context. Do fallback if comment is found wrong.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1053
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1054 (defvar cperl-wrong-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1055
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1056 (defun cperl-comment-indent ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1057 (let ((p (point)) (c (current-column)) was)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1058 (if (looking-at "^#") 0 ; Existing comment at bol stays there.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1059 ;; Wrong comment found
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1060 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1061 (setq was (cperl-to-comment-or-eol))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1062 (if (= (point) p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1063 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1064 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1065 (max (1+ (current-column)) ; Else indent at comment column
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1066 comment-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1067 (if was nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1068 (insert comment-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1069 (backward-char (length comment-start)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1070 (setq cperl-wrong-comment t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1071 (indent-to comment-column 1) ; Indent minimum 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1072 c))))) ; except leave at least one space.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1073
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1074 ;;;(defun cperl-comment-indent-fallback ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1075 ;;; "Is called if the standard comment-search procedure fails.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1076 ;;;Point is at start of real comment."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1077 ;;; (let ((c (current-column)) target cnt prevc)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1078 ;;; (if (= c comment-column) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1079 ;;; (setq cnt (skip-chars-backward "[ \t]"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1080 ;;; (setq target (max (1+ (setq prevc
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1081 ;;; (current-column))) ; Else indent at comment column
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1082 ;;; comment-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1083 ;;; (if (= c comment-column) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1084 ;;; (delete-backward-char cnt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1085 ;;; (while (< prevc target)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1086 ;;; (insert "\t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1087 ;;; (setq prevc (current-column)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1088 ;;; (if (> prevc target) (progn (delete-char -1) (setq prevc (current-column))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1089 ;;; (while (< prevc target)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1090 ;;; (insert " ")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1091 ;;; (setq prevc (current-column)))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1092
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1093 (defun cperl-indent-for-comment ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1094 "Substitute for `indent-for-comment' in CPerl."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1095 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1096 (let (cperl-wrong-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1097 (indent-for-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1098 (if cperl-wrong-comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1099 (progn (cperl-to-comment-or-eol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1100 (forward-char (length comment-start))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1101
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1102 (defun cperl-comment-region (b e arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1103 "Comment or uncomment each line in the region in CPerl mode.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1104 See `comment-region'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1105 (interactive "r\np")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1106 (let ((comment-start "#"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1107 (comment-region b e arg)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1108
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1109 (defun cperl-uncomment-region (b e arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1110 "Uncomment or comment each line in the region in CPerl mode.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1111 See `comment-region'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1112 (interactive "r\np")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1113 (let ((comment-start "#"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1114 (comment-region b e (- arg))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1115
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1116 (defvar cperl-brace-recursing nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1117
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1118 (defun cperl-electric-brace (arg &optional only-before)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1119 "Insert character and correct line's indentation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1120 If ONLY-BEFORE and `cperl-auto-newline', will insert newline before the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1121 place (even in empty line), but not after. If after \")\" and the inserted
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1122 char is \"{\", insert extra newline before only if
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1123 `cperl-extra-newline-before-brace'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1124 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1125 (let (insertpos
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1126 (other-end (if (and cperl-electric-parens-mark
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1127 (cperl-mark-active)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1128 (< (mark) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1129 (mark)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1130 nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1131 (if (and other-end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1132 (not cperl-brace-recursing)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1133 (cperl-val 'cperl-electric-parens)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1134 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1135 ;; Need to insert a matching pair
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1136 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1137 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1138 (setq insertpos (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1139 (goto-char other-end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1140 (setq last-command-char ?\{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1141 (cperl-electric-lbrace arg insertpos))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1142 (forward-char 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1143 (if (and (not arg) ; No args, end (of empty line or auto)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1144 (eolp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1145 (or (and (null only-before)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1146 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1147 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1148 (bolp)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1149 (and (eq last-command-char ?\{) ; Do not insert newline
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1150 ;; if after ")" and `cperl-extra-newline-before-brace'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1151 ;; is nil, do not insert extra newline.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1152 (not cperl-extra-newline-before-brace)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1153 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1154 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1155 (eq (preceding-char) ?\))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1156 (if cperl-auto-newline
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1157 (progn (cperl-indent-line) (newline) t) nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1158 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1159 (self-insert-command (prefix-numeric-value arg))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1160 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1161 (if cperl-auto-newline
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1162 (setq insertpos (1- (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1163 (if (and cperl-auto-newline (null only-before))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1164 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1165 (newline)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1166 (cperl-indent-line)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1167 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1168 (if insertpos (progn (goto-char insertpos)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1169 (search-forward (make-string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1170 1 last-command-char))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1171 (setq insertpos (1- (point)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1172 (delete-char -1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1173 (if insertpos
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1174 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1175 (goto-char insertpos)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1176 (self-insert-command (prefix-numeric-value arg)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1177 (self-insert-command (prefix-numeric-value arg))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1178
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1179 (defun cperl-electric-lbrace (arg &optional end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1180 "Insert character, correct line's indentation, correct quoting by space."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1181 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1182 (let (pos after
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1183 (cperl-brace-recursing t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1184 (cperl-auto-newline cperl-auto-newline)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1185 (other-end (or end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1186 (if (and cperl-electric-parens-mark
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1187 (cperl-mark-active)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1188 (> (mark) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1189 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1190 (goto-char (mark))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1191 (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1192 nil))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1193 (and (cperl-val 'cperl-electric-lbrace-space)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1194 (eq (preceding-char) ?$)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1195 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1196 (skip-chars-backward "$")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1197 (looking-at "\\(\\$\\$\\)*\\$\\([^\\$]\\|$\\)"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1198 (insert ?\ ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1199 (if (cperl-after-expr-p nil "{;)") nil (setq cperl-auto-newline nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1200 (cperl-electric-brace arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1201 (and (cperl-val 'cperl-electric-parens)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1202 (eq last-command-char ?{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1203 (memq last-command-char
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1204 (append cperl-electric-parens-string nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1205 (or (if other-end (goto-char (marker-position other-end)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1206 t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1207 (setq last-command-char ?} pos (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1208 (progn (cperl-electric-brace arg t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1209 (goto-char pos)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1210
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1211 (defun cperl-electric-paren (arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1212 "Insert a matching pair of parentheses."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1213 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1214 (let ((beg (save-excursion (beginning-of-line) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1215 (other-end (if (and cperl-electric-parens-mark
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1216 (cperl-mark-active)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1217 (> (mark) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1218 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1219 (goto-char (mark))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1220 (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1221 nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1222 (if (and (cperl-val 'cperl-electric-parens)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1223 (memq last-command-char
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1224 (append cperl-electric-parens-string nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1225 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1226 ;;(not (save-excursion (search-backward "#" beg t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1227 (if (eq last-command-char ?<)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1228 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1229 (and abbrev-mode ; later it is too late, may be after `for'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1230 (expand-abbrev))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1231 (cperl-after-expr-p nil "{;(,:="))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1232 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1233 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1234 (self-insert-command (prefix-numeric-value arg))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1235 (if other-end (goto-char (marker-position other-end)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1236 (insert (make-string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1237 (prefix-numeric-value arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1238 (cdr (assoc last-command-char '((?{ .?})
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1239 (?[ . ?])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1240 (?( . ?))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1241 (?< . ?>))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1242 (forward-char (- (prefix-numeric-value arg))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1243 (self-insert-command (prefix-numeric-value arg)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1244
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1245 (defun cperl-electric-rparen (arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1246 "Insert a matching pair of parentheses if marking is active.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1247 If not, or if we are not at the end of marking range, would self-insert."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1248 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1249 (let ((beg (save-excursion (beginning-of-line) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1250 (other-end (if (and cperl-electric-parens-mark
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1251 (cperl-val 'cperl-electric-parens)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1252 (memq last-command-char
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1253 (append cperl-electric-parens-string nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1254 (cperl-mark-active)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1255 (< (mark) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1256 (mark)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1257 nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1258 p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1259 (if (and other-end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1260 (cperl-val 'cperl-electric-parens)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1261 (memq last-command-char '( ?\) ?\] ?\} ?\> ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1262 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1263 ;;(not (save-excursion (search-backward "#" beg t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1264 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1265 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1266 (self-insert-command (prefix-numeric-value arg))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1267 (setq p (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1268 (if other-end (goto-char other-end))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1269 (insert (make-string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1270 (prefix-numeric-value arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1271 (cdr (assoc last-command-char '((?\} . ?\{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1272 (?\] . ?\[)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1273 (?\) . ?\()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1274 (?\> . ?\<))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1275 (goto-char (1+ p)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1276 (self-insert-command (prefix-numeric-value arg)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1277
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1278 (defun cperl-electric-keyword ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1279 "Insert a construction appropriate after a keyword."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1280 (let ((beg (save-excursion (beginning-of-line) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1281 (dollar (and (eq last-command-char ?$)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1282 (eq this-command 'self-insert-command)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1283 (delete (and (memq last-command-char '(?\ ?\n ?\t ?\f))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1284 (memq this-command '(self-insert-command newline)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1285 (and (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1286 (backward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1287 (cperl-after-expr-p nil "{;:"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1288 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1289 (not
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1290 (re-search-backward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1291 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1292 beg t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1293 (save-excursion (or (not (re-search-backward "^=" nil t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1294 (looking-at "=cut")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1295 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1296 (and dollar (insert " $"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1297 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1298 ;;(insert " () {\n}")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1299 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1300 (cperl-extra-newline-before-brace
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1301 (insert " ()\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1302 (insert "{")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1303 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1304 (insert "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1305 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1306 (insert "\n}"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1307 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1308 (insert " () {\n}"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1309 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1310 (or (looking-at "[ \t]\\|$") (insert " "))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1311 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1312 (if dollar (progn (search-backward "$")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1313 (delete-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1314 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1315 (forward-char 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1316 (search-backward ")"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1317 (if delete
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1318 (cperl-putback-char cperl-del-back-ch))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1319
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1320 (defun cperl-electric-else ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1321 "Insert a construction appropriate after a keyword."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1322 (let ((beg (save-excursion (beginning-of-line) (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1323 (and (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1324 (backward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1325 (cperl-after-expr-p nil "{;:"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1326 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1327 (not
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1328 (re-search-backward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1329 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1330 beg t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1331 (save-excursion (or (not (re-search-backward "^=" nil t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1332 (looking-at "=cut")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1333 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1334 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1335 ;;(insert " {\n\n}")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1336 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1337 (cperl-extra-newline-before-brace
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1338 (insert "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1339 (insert "{")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1340 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1341 (insert "\n\n}"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1342 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1343 (insert " {\n\n}"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1344 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1345 (or (looking-at "[ \t]\\|$") (insert " "))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1346 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1347 (forward-line -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1348 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1349 (cperl-putback-char cperl-del-back-ch)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1350
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1351 (defun cperl-linefeed ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1352 "Go to end of line, open a new line and indent appropriately."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1353 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1354 (let ((beg (save-excursion (beginning-of-line) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1355 (end (save-excursion (end-of-line) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1356 (pos (point)) start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1357 (if (and ; Check if we need to split:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1358 ; i.e., on a boundary and inside "{...}"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1359 (save-excursion (cperl-to-comment-or-eol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1360 (>= (point) pos)) ; Not in a comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1361 (or (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1362 (skip-chars-backward " \t" beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1363 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1364 (looking-at "[;{]")) ; After { or ; + spaces
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1365 (looking-at "[ \t]*}") ; Before }
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1366 (re-search-forward "\\=[ \t]*;" end t)) ; Before spaces + ;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1367 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1368 (and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1369 (eq (car (parse-partial-sexp pos end -1)) -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1370 ; Leave the level of parens
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1371 (looking-at "[,; \t]*\\($\\|#\\)") ; Comma to allow anon subr
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1372 ; Are at end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1373 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1374 (backward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1375 (setq start (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1376 (<= start pos))))) ; RedundantAre after the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1377 ; start of parens group.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1378 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1379 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1380 (or (memq (preceding-char) (append ";{" nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1381 (insert ";"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1382 (insert "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1383 (forward-line -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1384 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1385 (goto-char start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1386 (or (looking-at "{[ \t]*$") ; If there is a statement
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1387 ; before, move it to separate line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1388 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1389 (forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1390 (insert "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1391 (cperl-indent-line)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1392 (forward-line 1) ; We are on the target line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1393 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1394 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1395 (or (looking-at "[ \t]*}[,; \t]*$") ; If there is a statement
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1396 ; after, move it to separate line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1397 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1398 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1399 (search-backward "}" beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1400 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1401 (or (memq (preceding-char) (append ";{" nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1402 (insert ";"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1403 (insert "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1404 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1405 (forward-line -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1406 (forward-line -1) ; We are on the line before target
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1407 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1408 (newline-and-indent))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1409 (end-of-line) ; else
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1410 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1411 ((and (looking-at "\n[ \t]*{$")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1412 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1413 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1414 (eq (preceding-char) ?\)))) ; Probably if () {} group
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1415 ; with an extra newline.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1416 (forward-line 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1417 (cperl-indent-line))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1418 ((looking-at "\n[ \t]*$") ; Next line is empty - use it.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1419 (forward-line 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1420 (cperl-indent-line))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1421 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1422 (newline-and-indent))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1423
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1424 (defun cperl-electric-semi (arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1425 "Insert character and correct line's indentation."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1426 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1427 (if cperl-auto-newline
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1428 (cperl-electric-terminator arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1429 (self-insert-command (prefix-numeric-value arg))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1430
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1431 (defun cperl-electric-terminator (arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1432 "Insert character and correct line's indentation."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1433 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1434 (let (insertpos (end (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1435 (auto (and cperl-auto-newline
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1436 (or (not (eq last-command-char ?:))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1437 cperl-auto-newline-after-colon))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1438 (if (and ;;(not arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1439 (eolp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1440 (not (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1441 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1442 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1443 (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1444 ;; Ignore in comment lines
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1445 (= (following-char) ?#)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1446 ;; Colon is special only after a label
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1447 ;; So quickly rule out most other uses of colon
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1448 ;; and do no indentation for them.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1449 (and (eq last-command-char ?:)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1450 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1451 (forward-word 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1452 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1453 (and (< (point) end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1454 (progn (goto-char (- end 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1455 (not (looking-at ":"))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1456 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1457 (beginning-of-defun)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1458 (let ((pps (parse-partial-sexp (point) end)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1459 (or (nth 3 pps) (nth 4 pps) (nth 5 pps))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1460 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1461 (self-insert-command (prefix-numeric-value arg))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1462 ;;(forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1463 (if auto (setq insertpos (point-marker)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1464 ;;(forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1465 (cperl-indent-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1466 (if auto
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1467 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1468 (newline)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1469 (cperl-indent-line)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1470 ;; (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1471 ;; (if insertpos (progn (goto-char (marker-position insertpos))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1472 ;; (search-forward (make-string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1473 ;; 1 last-command-char))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1474 ;; (setq insertpos (1- (point)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1475 ;; (delete-char -1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1476 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1477 (if insertpos (goto-char (1- (marker-position insertpos)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1478 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1479 (delete-char 1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1480 (if insertpos
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1481 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1482 (goto-char insertpos)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1483 (self-insert-command (prefix-numeric-value arg)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1484 (self-insert-command (prefix-numeric-value arg)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1485
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1486 (defun cperl-electric-backspace (arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1487 "Backspace-untabify, or remove the whitespace inserted by an electric key."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1488 (interactive "p")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1489 (if (and cperl-auto-newline
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1490 (memq last-command '(cperl-electric-semi
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1491 cperl-electric-terminator
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1492 cperl-electric-lbrace))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1493 (memq (preceding-char) '(?\ ?\t ?\n)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1494 (let (p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1495 (if (eq last-command 'cperl-electric-lbrace)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1496 (skip-chars-forward " \t\n"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1497 (setq p (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1498 (skip-chars-backward " \t\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1499 (delete-region (point) p))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1500 (backward-delete-char-untabify arg)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1501
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1502 (defun cperl-inside-parens-p ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1503 (condition-case ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1504 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1505 (save-restriction
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1506 (narrow-to-region (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1507 (progn (beginning-of-defun) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1508 (goto-char (point-max))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1509 (= (char-after (or (scan-lists (point) -1 1) (point-min))) ?\()))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1510 (error nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1511
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1512 (defun cperl-indent-command (&optional whole-exp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1513 "Indent current line as Perl code, or in some cases insert a tab character.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1514 If `cperl-tab-always-indent' is non-nil (the default), always indent current line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1515 Otherwise, indent the current line only if point is at the left margin
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1516 or in the line's indentation; otherwise insert a tab.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1517
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1518 A numeric argument, regardless of its value,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1519 means indent rigidly all the lines of the expression starting after point
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1520 so that this line becomes properly indented.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1521 The relative indentation among the lines of the expression are preserved."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1522 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1523 (if whole-exp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1524 ;; If arg, always indent this line as Perl
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1525 ;; and shift remaining lines of expression the same amount.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1526 (let ((shift-amt (cperl-indent-line))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1527 beg end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1528 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1529 (if cperl-tab-always-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1530 (beginning-of-line))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1531 (setq beg (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1532 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1533 (setq end (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1534 (goto-char beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1535 (forward-line 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1536 (setq beg (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1537 (if (> end beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1538 (indent-code-rigidly beg end shift-amt "#")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1539 (if (and (not cperl-tab-always-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1540 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1541 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1542 (not (bolp))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1543 (insert-tab)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1544 (cperl-indent-line))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1545
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1546 (defun cperl-indent-line (&optional symbol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1547 "Indent current line as Perl code.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1548 Return the amount the indentation changed by."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1549 (let (indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1550 beg shift-amt
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1551 (case-fold-search nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1552 (pos (- (point-max) (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1553 (setq indent (cperl-calculate-indent nil symbol))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1554 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1555 (setq beg (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1556 (cond ((or (eq indent nil) (eq indent t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1557 (setq indent (current-indentation)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1558 ;;((eq indent t) ; Never?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1559 ;; (setq indent (cperl-calculate-indent-within-comment)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1560 ;;((looking-at "[ \t]*#")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1561 ;; (setq indent 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1562 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1563 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1564 (if (listp indent) (setq indent (car indent)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1565 (cond ((looking-at "[A-Za-z_][A-Za-z_0-9]*:[^:]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1566 (and (> indent 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1567 (setq indent (max cperl-min-label-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1568 (+ indent cperl-label-offset)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1569 ((= (following-char) ?})
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1570 (setq indent (- indent cperl-indent-level)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1571 ((memq (following-char) '(?\) ?\])) ; To line up with opening paren.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1572 (setq indent (+ indent cperl-close-paren-offset)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1573 ((= (following-char) ?{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1574 (setq indent (+ indent cperl-brace-offset))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1575 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1576 (setq shift-amt (- indent (current-column)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1577 (if (zerop shift-amt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1578 (if (> (- (point-max) pos) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1579 (goto-char (- (point-max) pos)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1580 (delete-region beg (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1581 (indent-to indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1582 ;; If initial point was within line's indentation,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1583 ;; position after the indentation. Else stay at same point in text.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1584 (if (> (- (point-max) pos) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1585 (goto-char (- (point-max) pos))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1586 shift-amt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1587
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1588 (defun cperl-after-label ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1589 ;; Returns true if the point is after label. Does not do save-excursion.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1590 (and (eq (preceding-char) ?:)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1591 (memq (char-syntax (char-after (- (point) 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1592 '(?w ?_))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1593 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1594 (backward-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1595 (looking-at "[a-zA-Z_][a-zA-Z0-9_]*:[^:]"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1596
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1597 (defun cperl-get-state (&optional parse-start start-state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1598 ;; returns list (START STATE DEPTH PRESTART), START is a good place
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1599 ;; to start parsing, STATE is what is returned by
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1600 ;; `parse-partial-sexp'. DEPTH is true is we are immediately after
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1601 ;; end of block which contains START. PRESTART is the position
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1602 ;; basing on which START was found.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1603 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1604 (let ((start-point (point)) depth state start prestart)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1605 (if parse-start
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1606 (goto-char parse-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1607 (beginning-of-defun))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1608 (setq prestart (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1609 (if start-state nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1610 ;; Try to go out, if sub is not on the outermost level
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1611 (while (< (point) start-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1612 (setq start (point) parse-start start depth nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1613 state (parse-partial-sexp start start-point -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1614 (if (> (car state) -1) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1615 ;; The current line could start like }}}, so the indentation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1616 ;; corresponds to a different level than what we reached
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1617 (setq depth t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1618 (beginning-of-line 2))) ; Go to the next line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1619 (if start (goto-char start))) ; Not at the start of file
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1620 (setq start (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1621 (if (< start start-point) (setq parse-start start))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1622 (or state (setq state (parse-partial-sexp start start-point -1 nil start-state)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1623 (list start state depth prestart))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1624
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1625 (defun cperl-block-p () ; Do not C-M-q ! One string contains ";" !
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1626 ;; Positions is before ?\{. Checks whether it starts a block.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1627 ;; No save-excursion!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1628 (cperl-backward-to-noncomment (point-min))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1629 ;;(skip-chars-backward " \t\n\f")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1630 (or (memq (preceding-char) (append ";){}$@&%\C-@" nil)) ; Or label! \C-@ at bobp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1631 ; Label may be mixed up with `$blah :'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1632 (save-excursion (cperl-after-label))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1633 (and (memq (char-syntax (preceding-char)) '(?w ?_))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1634 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1635 (backward-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1636 ;; Need take into account `bless', `return', `tr',...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1637 (or (and (looking-at "[a-zA-Z0-9_:]+[ \t\n\f]*[{#]") ; Method call syntax
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1638 (not (looking-at "\\(bless\\|return\\|qw\\|tr\\|[smy]\\)\\>")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1639 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1640 (skip-chars-backward " \t\n\f")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1641 (and (memq (char-syntax (preceding-char)) '(?w ?_))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1642 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1643 (backward-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1644 (looking-at
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1645 "sub[ \t]+[a-zA-Z0-9_:]+[ \t\n\f]*\\(([^()]*)[ \t\n\f]*\\)?[#{]")))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1646
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1647 (defvar cperl-look-for-prop '((pod in-pod) (here-doc-delim here-doc-group)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1648
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1649 (defun cperl-calculate-indent (&optional parse-start symbol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1650 "Return appropriate indentation for current line as Perl code.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1651 In usual case returns an integer: the column to indent to.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1652 Returns nil if line starts inside a string, t if in a comment."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1653 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1654 (if (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1655 (memq (get-text-property (point) 'syntax-type)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1656 '(pod here-doc here-doc-delim format))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1657 ;; before start of POD - whitespace found since do not have 'pod!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1658 (and (looking-at "[ \t]*\n=")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1659 (error "Spaces before pod section!"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1660 (and (not cperl-indent-left-aligned-comments)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1661 (looking-at "^#")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1662 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1663 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1664 (let ((indent-point (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1665 (char-after (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1666 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1667 (following-char)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1668 (in-pod (get-text-property (point) 'in-pod))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1669 (pre-indent-point (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1670 p prop look-prop)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1671 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1672 (in-pod
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1673 ;; In the verbatim part, probably code example. What to do???
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1674 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1675 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1676 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1677 ;; Not in pod
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1678 (cperl-backward-to-noncomment nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1679 (setq p (max (point-min) (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1680 prop (get-text-property p 'syntax-type)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1681 look-prop (or (nth 1 (assoc prop cperl-look-for-prop))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1682 'syntax-type))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1683 (if (memq prop '(pod here-doc format here-doc-delim))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1684 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1685 (goto-char (or (previous-single-property-change p look-prop)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1686 (point-min)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1687 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1688 (setq pre-indent-point (point)))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1689 (goto-char pre-indent-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1690 (let* ((case-fold-search nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1691 (s-s (cperl-get-state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1692 (start (nth 0 s-s))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1693 (state (nth 1 s-s))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1694 (containing-sexp (car (cdr state)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1695 (start-indent (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1696 (goto-char start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1697 (- (current-indentation)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1698 (if (nth 2 s-s) cperl-indent-level 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1699 old-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1700 ;; (or parse-start (null symbol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1701 ;; (setq parse-start (symbol-value symbol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1702 ;; start-indent (nth 2 parse-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1703 ;; parse-start (car parse-start)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1704 ;; (if parse-start
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1705 ;; (goto-char parse-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1706 ;; (beginning-of-defun))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1707 ;; ;; Try to go out
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1708 ;; (while (< (point) indent-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1709 ;; (setq start (point) parse-start start moved nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1710 ;; state (parse-partial-sexp start indent-point -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1711 ;; (if (> (car state) -1) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1712 ;; ;; The current line could start like }}}, so the indentation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1713 ;; ;; corresponds to a different level than what we reached
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1714 ;; (setq moved t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1715 ;; (beginning-of-line 2))) ; Go to the next line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1716 ;; (if start ; Not at the start of file
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1717 ;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1718 ;; (goto-char start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1719 ;; (setq start-indent (current-indentation))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1720 ;; (if moved ; Should correct...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1721 ;; (setq start-indent (- start-indent cperl-indent-level))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1722 ;; (setq start-indent 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1723 ;; (if (< (point) indent-point) (setq parse-start (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1724 ;; (or state (setq state (parse-partial-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1725 ;; (point) indent-point -1 nil start-state)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1726 ;; (setq containing-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1727 ;; (or (car (cdr state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1728 ;; (and (>= (nth 6 state) 0) old-containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1729 ;; old-containing-sexp nil start-state nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1730 ;;;; (while (< (point) indent-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1731 ;;;; (setq parse-start (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1732 ;;;; (setq state (parse-partial-sexp (point) indent-point -1 nil start-state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1733 ;;;; (setq containing-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1734 ;;;; (or (car (cdr state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1735 ;;;; (and (>= (nth 6 state) 0) old-containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1736 ;;;; old-containing-sexp nil start-state nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1737 ;; (if symbol (set symbol (list indent-point state start-indent)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1738 ;; (goto-char indent-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1739 (cond ((or (nth 3 state) (nth 4 state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1740 ;; return nil or t if should not change this line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1741 (nth 4 state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1742 ((null containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1743 ;; Line is at top level. May be data or function definition,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1744 ;; or may be function argument declaration.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1745 ;; Indent like the previous top level line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1746 ;; unless that ends in a closeparen without semicolon,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1747 ;; in which case this line is the first argument decl.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1748 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1749 (+ start-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1750 (if (= (following-char) ?{) cperl-continued-brace-offset 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1751 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1752 (cperl-backward-to-noncomment (or parse-start (point-min)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1753 ;;(skip-chars-backward " \t\f\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1754 ;; Look at previous line that's at column 0
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1755 ;; to determine whether we are in top-level decls
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1756 ;; or function's arg decls. Set basic-indent accordingly.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1757 ;; Now add a little if this is a continuation line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1758 (if (or (bobp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1759 (memq (preceding-char) (append " ;}" nil)) ; Was ?\)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1760 (memq char-after (append ")]}" nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1761 (and (eq (preceding-char) ?\:) ; label
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1762 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1763 (forward-sexp -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1764 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1765 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1766 0
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1767 cperl-continued-statement-offset))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1768 ((/= (char-after containing-sexp) ?{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1769 ;; line is expression, not statement:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1770 ;; indent to just after the surrounding open,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1771 ;; skip blanks if we do not close the expression.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1772 (goto-char (1+ containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1773 (or (memq char-after (append ")]}" nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1774 (looking-at "[ \t]*\\(#\\|$\\)")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1775 (skip-chars-forward " \t"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1776 (current-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1777 ((progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1778 ;; Containing-expr starts with \{. Check whether it is a hash.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1779 (goto-char containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1780 (not (cperl-block-p)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1781 (goto-char (1+ containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1782 (or (eq char-after ?\})
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1783 (looking-at "[ \t]*\\(#\\|$\\)")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1784 (skip-chars-forward " \t"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1785 (+ (current-column) ; Correct indentation of trailing ?\}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1786 (if (eq char-after ?\}) (+ cperl-indent-level
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1787 cperl-close-paren-offset)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1788 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1789 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1790 ;; Statement level. Is it a continuation or a new statement?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1791 ;; Find previous non-comment character.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1792 (goto-char pre-indent-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1793 (cperl-backward-to-noncomment containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1794 ;; Back up over label lines, since they don't
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1795 ;; affect whether our line is a continuation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1796 (while (or (eq (preceding-char) ?\,)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1797 (and (eq (preceding-char) ?:)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1798 (or;;(eq (char-after (- (point) 2)) ?\') ; ????
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1799 (memq (char-syntax (char-after (- (point) 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1800 '(?w ?_)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1801 (if (eq (preceding-char) ?\,)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1802 ;; Will go to beginning of line, essentially.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1803 ;; Will ignore embedded sexpr XXXX.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1804 (cperl-backward-to-start-of-continued-exp containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1805 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1806 (cperl-backward-to-noncomment containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1807 ;; Now we get the answer.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1808 (if (not (memq (preceding-char) (append ", ;}{" '(nil)))) ; Was ?\,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1809 ;; This line is continuation of preceding line's statement;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1810 ;; indent `cperl-continued-statement-offset' more than the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1811 ;; previous line of the statement.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1812 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1813 (cperl-backward-to-start-of-continued-exp containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1814 (+ (if (memq char-after (append "}])" nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1815 0 ; Closing parenth
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1816 cperl-continued-statement-offset)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1817 (current-column)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1818 (if (eq char-after ?\{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1819 cperl-continued-brace-offset 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1820 ;; This line starts a new statement.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1821 ;; Position following last unclosed open.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1822 (goto-char containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1823 ;; Is line first statement after an open-brace?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1824 (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1825 ;; If no, find that first statement and indent like
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1826 ;; it. If the first statement begins with label, do
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1827 ;; not believe when the indentation of the label is too
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1828 ;; small.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1829 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1830 (forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1831 (setq old-indent (current-indentation))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1832 (let ((colon-line-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1833 (while (progn (skip-chars-forward " \t\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1834 (looking-at "#\\|[a-zA-Z0-9_$]*:[^:]"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1835 ;; Skip over comments and labels following openbrace.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1836 (cond ((= (following-char) ?\#)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1837 (forward-line 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1838 ;; label:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1839 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1840 (save-excursion (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1841 (setq colon-line-end (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1842 (search-forward ":"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1843 ;; The first following code counts
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1844 ;; if it is before the line we want to indent.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1845 (and (< (point) indent-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1846 (if (> colon-line-end (point)) ; After label
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1847 (if (> (current-indentation)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1848 cperl-min-label-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1849 (- (current-indentation) cperl-label-offset)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1850 ;; Do not believe: `max' is involved
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1851 (+ old-indent cperl-indent-level))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1852 (current-column)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1853 ;; If no previous statement,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1854 ;; indent it relative to line brace is on.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1855 ;; For open brace in column zero, don't let statement
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1856 ;; start there too. If cperl-indent-level is zero,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1857 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1858 ;; For open-braces not the first thing in a line,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1859 ;; add in cperl-brace-imaginary-offset.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1860
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1861 ;; If first thing on a line: ?????
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1862 (+ (if (and (bolp) (zerop cperl-indent-level))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1863 (+ cperl-brace-offset cperl-continued-statement-offset)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1864 cperl-indent-level)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1865 ;; Move back over whitespace before the openbrace.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1866 ;; If openbrace is not first nonwhite thing on the line,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1867 ;; add the cperl-brace-imaginary-offset.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1868 (progn (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1869 (if (bolp) 0 cperl-brace-imaginary-offset))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1870 ;; If the openbrace is preceded by a parenthesized exp,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1871 ;; move to the beginning of that;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1872 ;; possibly a different line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1873 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1874 (if (eq (preceding-char) ?\))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1875 (forward-sexp -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1876 ;; In the case it starts a subroutine, indent with
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1877 ;; respect to `sub', not with respect to the the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1878 ;; first thing on the line, say in the case of
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1879 ;; anonymous sub in a hash.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1880 ;;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1881 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1882 (if (and (eq (preceding-char) ?b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1883 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1884 (forward-sexp -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1885 (looking-at "sub\\>"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1886 (setq old-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1887 (nth 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1888 (parse-partial-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1889 (save-excursion (beginning-of-line) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1890 (point)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1891 (progn (goto-char (1+ old-indent))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1892 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1893 (current-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1894 ;; Get initial indentation of the line we are on.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1895 ;; If line starts with label, calculate label indentation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1896 (if (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1897 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1898 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*:[^:]"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1899 (if (> (current-indentation) cperl-min-label-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1900 (- (current-indentation) cperl-label-offset)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1901 (cperl-calculate-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1902 (if (and parse-start (<= parse-start (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1903 parse-start)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1904 (current-indentation))))))))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1905
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1906 (defvar cperl-indent-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1907 '((string nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1908 (comment nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1909 (toplevel 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1910 (toplevel-after-parenth 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1911 (toplevel-continued 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1912 (expression 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1913 "Alist of indentation rules for CPerl mode.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1914 The values mean:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1915 nil: do not indent;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1916 number: add this amount of indentation.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1917
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1918 (defun cperl-where-am-i (&optional parse-start start-state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1919 ;; Unfinished
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1920 "Return a list of lists ((TYPE POS)...) of good points before the point.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1921 POS may be nil if it is hard to find, say, when TYPE is `string' or `comment'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1922 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1923 (let* ((start-point (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1924 (s-s (cperl-get-state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1925 (start (nth 0 s-s))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1926 (state (nth 1 s-s))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1927 (prestart (nth 3 s-s))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1928 (containing-sexp (car (cdr state)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1929 (case-fold-search nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1930 (res (list (list 'parse-start start) (list 'parse-prestart prestart))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1931 (cond ((nth 3 state) ; In string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1932 (setq res (cons (list 'string nil (nth 3 state)) res))) ; What started string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1933 ((nth 4 state) ; In comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1934 (setq res (cons '(comment) res)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1935 ((null containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1936 ;; Line is at top level.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1937 ;; Indent like the previous top level line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1938 ;; unless that ends in a closeparen without semicolon,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1939 ;; in which case this line is the first argument decl.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1940 (cperl-backward-to-noncomment (or parse-start (point-min)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1941 ;;(skip-chars-backward " \t\f\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1942 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1943 ((or (bobp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1944 (memq (preceding-char) (append ";}" nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1945 (setq res (cons (list 'toplevel start) res)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1946 ((eq (preceding-char) ?\) )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1947 (setq res (cons (list 'toplevel-after-parenth start) res)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1948 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1949 (setq res (cons (list 'toplevel-continued start) res)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1950 ((/= (char-after containing-sexp) ?{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1951 ;; line is expression, not statement:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1952 ;; indent to just after the surrounding open.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1953 ;; skip blanks if we do not close the expression.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1954 (setq res (cons (list 'expression-blanks
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1955 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1956 (goto-char (1+ containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1957 (or (looking-at "[ \t]*\\(#\\|$\\)")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1958 (skip-chars-forward " \t"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1959 (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1960 (cons (list 'expression containing-sexp) res))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1961 ((progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1962 ;; Containing-expr starts with \{. Check whether it is a hash.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1963 (goto-char containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1964 (not (cperl-block-p)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1965 (setq res (cons (list 'expression-blanks
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1966 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1967 (goto-char (1+ containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1968 (or (looking-at "[ \t]*\\(#\\|$\\)")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1969 (skip-chars-forward " \t"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1970 (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1971 (cons (list 'expression containing-sexp) res))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1972 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1973 ;; Statement level.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1974 (setq res (cons (list 'in-block containing-sexp) res))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1975 ;; Is it a continuation or a new statement?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1976 ;; Find previous non-comment character.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1977 (cperl-backward-to-noncomment containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1978 ;; Back up over label lines, since they don't
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1979 ;; affect whether our line is a continuation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1980 ;; Back up comma-delimited lines too ?????
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1981 (while (or (eq (preceding-char) ?\,)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1982 (save-excursion (cperl-after-label)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1983 (if (eq (preceding-char) ?\,)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1984 ;; Will go to beginning of line, essentially
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1985 ;; Will ignore embedded sexpr XXXX.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1986 (cperl-backward-to-start-of-continued-exp containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1987 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1988 (cperl-backward-to-noncomment containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1989 ;; Now we get the answer.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1990 (if (not (memq (preceding-char) (append ";}{" '(nil)))) ; Was ?\,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1991 ;; This line is continuation of preceding line's statement.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1992 (list (list 'statement-continued containing-sexp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1993 ;; This line starts a new statement.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1994 ;; Position following last unclosed open.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1995 (goto-char containing-sexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1996 ;; Is line first statement after an open-brace?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1997 (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1998 ;; If no, find that first statement and indent like
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1999 ;; it. If the first statement begins with label, do
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2000 ;; not believe when the indentation of the label is too
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2001 ;; small.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2002 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2003 (forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2004 (let ((colon-line-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2005 (while (progn (skip-chars-forward " \t\n" start-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2006 (and (< (point) start-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2007 (looking-at
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2008 "#\\|[a-zA-Z_][a-zA-Z0-9_]*:[^:]")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2009 ;; Skip over comments and labels following openbrace.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2010 (cond ((= (following-char) ?\#)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2011 ;;(forward-line 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2012 (end-of-line))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2013 ;; label:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2014 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2015 (save-excursion (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2016 (setq colon-line-end (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2017 (search-forward ":"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2018 ;; Now at the point, after label, or at start
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2019 ;; of first statement in the block.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2020 (and (< (point) start-point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2021 (if (> colon-line-end (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2022 ;; Before statement after label
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2023 (if (> (current-indentation)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2024 cperl-min-label-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2025 (list (list 'label-in-block (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2026 ;; Do not believe: `max' is involved
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2027 (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2028 (list 'label-in-block-min-indent (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2029 ;; Before statement
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2030 (list 'statement-in-block (point))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2031 ;; If no previous statement,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2032 ;; indent it relative to line brace is on.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2033 ;; For open brace in column zero, don't let statement
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2034 ;; start there too. If cperl-indent-level is zero,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2035 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2036 ;; For open-braces not the first thing in a line,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2037 ;; add in cperl-brace-imaginary-offset.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2038
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2039 ;; If first thing on a line: ?????
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2040 (+ (if (and (bolp) (zerop cperl-indent-level))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2041 (+ cperl-brace-offset cperl-continued-statement-offset)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2042 cperl-indent-level)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2043 ;; Move back over whitespace before the openbrace.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2044 ;; If openbrace is not first nonwhite thing on the line,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2045 ;; add the cperl-brace-imaginary-offset.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2046 (progn (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2047 (if (bolp) 0 cperl-brace-imaginary-offset))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2048 ;; If the openbrace is preceded by a parenthesized exp,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2049 ;; move to the beginning of that;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2050 ;; possibly a different line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2051 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2052 (if (eq (preceding-char) ?\))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2053 (forward-sexp -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2054 ;; Get initial indentation of the line we are on.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2055 ;; If line starts with label, calculate label indentation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2056 (if (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2057 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2058 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*:[^:]"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2059 (if (> (current-indentation) cperl-min-label-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2060 (- (current-indentation) cperl-label-offset)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2061 (cperl-calculate-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2062 (if (and parse-start (<= parse-start (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2063 parse-start)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2064 (current-indentation))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2065 res)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2066
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2067 (defun cperl-calculate-indent-within-comment ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2068 "Return the indentation amount for line, assuming that
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2069 the current line is to be regarded as part of a block comment."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2070 (let (end star-start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2071 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2072 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2073 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2074 (setq end (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2075 (and (= (following-char) ?#)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2076 (forward-line -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2077 (cperl-to-comment-or-eol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2078 (setq end (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2079 (goto-char end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2080 (current-column))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2081
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2082
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2083 (defun cperl-to-comment-or-eol ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2084 "Goes to position before comment on the current line, or to end of line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2085 Returns true if comment is found."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2086 (let (state stop-in cpoint (lim (progn (end-of-line) (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2087 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2088 (if (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2089 (eq (get-text-property (point) 'syntax-type) 'pod)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2090 (re-search-forward "\\=[ \t]*\\(#\\|$\\)" lim t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2091 (if (eq (preceding-char) ?\#) (progn (backward-char 1) t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2092 ;; Else
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2093 (while (not stop-in)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2094 (setq state (parse-partial-sexp (point) lim nil nil nil t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2095 ; stop at comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2096 ;; If fails (beginning-of-line inside sexp), then contains not-comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2097 ;; Do simplified processing
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2098 ;;(if (re-search-forward "[^$]#" lim 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2099 ;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2100 ;; (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2101 ;; (skip-chars-backward " \t\n\f" lim))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2102 ;; (goto-char lim)) ; No `#' at all
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2103 ;;)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2104 (if (nth 4 state) ; After `#';
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2105 ; (nth 2 state) can be
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2106 ; beginning of m,s,qq and so
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2107 ; on
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2108 (if (nth 2 state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2109 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2110 (setq cpoint (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2111 (goto-char (nth 2 state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2112 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2113 ((looking-at "\\(s\\|tr\\)\\>")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2114 (or (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2115 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2116 lim 'move)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2117 (setq stop-in t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2118 ((looking-at "\\(m\\|q\\([qxw]\\)?\\)\\>")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2119 (or (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2120 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2121 lim 'move)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2122 (setq stop-in t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2123 (t ; It was fair comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2124 (setq stop-in t) ; Finish
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2125 (goto-char (1- cpoint)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2126 (setq stop-in t) ; Finish
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2127 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2128 (setq stop-in t)) ; Finish
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2129 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2130 (nth 4 state))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2131
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2132 (defsubst cperl-1- (p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2133 (max (point-min) (1- p)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2134
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2135 (defsubst cperl-1+ (p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2136 (min (point-max) (1+ p)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2137
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2138 (defvar cperl-st-cfence '(14)) ; Comment-fence
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2139 (defvar cperl-st-sfence '(15)) ; String-fence
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2140 (defvar cperl-st-punct '(1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2141 (defvar cperl-st-word '(2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2142 (defvar cperl-st-bra '(4 . ?\>))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2143 (defvar cperl-st-ket '(5 . ?\<))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2144
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2145 (defsubst cperl-modify-syntax-type (at how)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2146 (if (< at (point-max))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2147 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2148 (put-text-property at (1+ at) 'syntax-table how)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2149 (put-text-property at (1+ at) 'rear-nonsticky t))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2150
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2151 (defun cperl-protect-defun-start (s e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2152 ;; C code looks for "^\\s(" to skip comment backward in "hard" situations
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2153 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2154 (goto-char s)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2155 (while (re-search-forward "^\\s(" e 'to-end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2156 (put-text-property (1- (point)) (point) 'syntax-table cperl-st-punct))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2157
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2158 (defun cperl-commentify (bb e string)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2159 (if cperl-use-syntax-table-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2160 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2161 ;; We suppose that e is _after_ the end of construction, as after eol.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2162 (setq string (if string cperl-st-sfence cperl-st-cfence))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2163 (cperl-modify-syntax-type bb string)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2164 (cperl-modify-syntax-type (1- e) string)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2165 (if (and (eq string cperl-st-sfence) (> (- e 2) bb))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2166 (put-text-property (1+ bb) (1- e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2167 'syntax-table cperl-string-syntax-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2168 (cperl-protect-defun-start bb e))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2169
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2170 (defun cperl-forward-re (lim end is-2arg set-st st-l err-l argument
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2171 &optional ostart oend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2172 ;; Works *before* syntax recognition is done
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2173 ;; May modify syntax-type text property if the situation is too hard
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2174 (let (b starter ender st i i2 go-forward)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2175 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2176 ;; ender means matching-char matcher.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2177 (setq b (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2178 starter (char-after b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2179 ;; ender:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2180 ender (cdr (assoc starter '(( ?\( . ?\) )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2181 ( ?\[ . ?\] )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2182 ( ?\{ . ?\} )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2183 ( ?\< . ?\> )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2184 ))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2185 ;; What if starter == ?\\ ????
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2186 (if set-st
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2187 (if (car st-l)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2188 (setq st (car st-l))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2189 (setcar st-l (make-syntax-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2190 (setq i 0 st (car st-l))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2191 (while (< i 256)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2192 (modify-syntax-entry i "." st)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2193 (setq i (1+ i)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2194 (modify-syntax-entry ?\\ "\\" st)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2195 (setq set-st t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2196 ;; Whether we have an intermediate point
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2197 (setq i nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2198 ;; Prepare the syntax table:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2199 (and set-st
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2200 (if (not ender) ; m/blah/, s/x//, s/x/y/
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2201 (modify-syntax-entry starter "$" st)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2202 (modify-syntax-entry starter (concat "(" (list ender)) st)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2203 (modify-syntax-entry ender (concat ")" (list starter)) st)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2204 (condition-case bb
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2205 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2206 (if (and (eq starter (char-after (cperl-1+ b)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2207 (not ender))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2208 ;; $ has TeXish matching rules, so $$ equiv $...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2209 (forward-char 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2210 (set-syntax-table st)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2211 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2212 (set-syntax-table cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2213 ;; Now the problem is with m;blah;;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2214 (and (not ender)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2215 (eq (preceding-char)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2216 (char-after (- (point) 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2217 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2218 (forward-char -2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2219 (= 0 (% (skip-chars-backward "\\\\") 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2220 (forward-char -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2221 (and is-2arg ; Have trailing part
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2222 (not ender)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2223 (eq (following-char) starter) ; Empty trailing part
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2224 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2225 (or (eq (char-syntax (following-char)) ?.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2226 ;; Make trailing letter into punctuation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2227 (cperl-modify-syntax-type (point) cperl-st-punct))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2228 (setq is-2arg nil go-forward t))) ; Ignore the tail
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2229 (if is-2arg ; Not number => have second part
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2230 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2231 (setq i (point) i2 i)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2232 (if ender
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2233 (if (memq (following-char) '(?\ ?\t ?\n ?\f))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2234 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2235 (if (looking-at "[ \t\n\f]+\\(#[^\n]*\n[ \t\n\f]*\\)+")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2236 (goto-char (match-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2237 (skip-chars-forward " \t\n\f"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2238 (setq i2 (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2239 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2240 (modify-syntax-entry starter (if (eq starter ?\\) "\\" ".") st)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2241 (if ender (modify-syntax-entry ender "." st))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2242 (setq set-st nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2243 (setq
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2244 ender
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2245 (cperl-forward-re lim end nil t st-l err-l argument starter ender)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2246 ender (nth 2 ender)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2247 (error (goto-char lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2248 (setq set-st nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2249 (or end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2250 (message
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2251 "End of `%s%s%c ... %c' string not found: %s"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2252 argument
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2253 (if ostart (format "%c ... %c" ostart (or oend ostart)) "")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2254 starter (or ender starter) bb)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2255 (or (car err-l) (setcar err-l b)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2256 (if set-st
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2257 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2258 (modify-syntax-entry starter (if (eq starter ?\\) "\\" ".") st)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2259 (if ender (modify-syntax-entry ender "." st))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2260 (list i i2 ender starter go-forward)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2261
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2262 (defun cperl-find-pods-heres (&optional min max non-inter end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2263 "Scans the buffer for hard-to-parse Perl constructions.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2264 If `cperl-pod-here-fontify' is not-nil after evaluation, will fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2265 the sections using `cperl-pod-head-face', `cperl-pod-face',
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2266 `cperl-here-face'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2267 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2268 (or min (setq min (point-min)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2269 (or max (setq max (point-max)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2270 (let (face head-face here-face b e bb tag qtag b1 e1 argument i c tail state
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2271 (cperl-pod-here-fontify (eval cperl-pod-here-fontify)) go
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2272 (case-fold-search nil) (inhibit-read-only t) (buffer-undo-list t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2273 (modified (buffer-modified-p))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2274 (after-change-functions nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2275 (state-point (point-min))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2276 (st-l '(nil)) (err-l '(nil)) i2
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2277 ;; Somehow font-lock may be not loaded yet...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2278 (font-lock-string-face (if (boundp 'font-lock-string-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2279 font-lock-string-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2280 'font-lock-string-face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2281 (search
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2282 (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2283 "\\(\\`\n?\\|\n\n\\)="
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2284 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2285 ;; One extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2286 "<<"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2287 "\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2288 ;; First variant "BLAH" or just ``.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2289 "\\([\"'`]\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2290 "\\([^\"'`\n]*\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2291 "\\3"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2292 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2293 ;; Second variant: Identifier or empty
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2294 "\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2295 ;; Check that we do not have <<= or << 30 or << $blah.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2296 "\\([^= \t$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2297 "\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2298 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2299 ;; 1+6 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2300 "^[ \t]*\\(format\\)[ \t]*\\([a-zA-Z0-9_]+\\)?[ \t]*=[ \t]*$"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2301 (if cperl-use-syntax-table-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2302 (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2303 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2304 ;; 1+6+2=9 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2305 "\\<\\(q[wxq]?\\|[msy]\\|tr\\)\\>"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2306 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2307 ;; 1+6+2+1=10 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2308 "\\([?/]\\)" ; /blah/ or ?blah?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2309 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2310 ;; 1+6+2+1+1=11 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2311 "\\<sub\\>[ \t]*\\([a-zA-Z_:'0-9]+[ \t]*\\)?\\(([^()]*)\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2312 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2313 ;; 1+6+2+1+1+2=13 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2314 "\\$\\(['{]\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2315 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2316 ;; 1+6+2+1+1+2+1=14 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2317 "\\(\\<sub[ \t\n\f]+\\|[&*$@%]\\)[a-zA-Z0-9_]*'"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2318 ;; 1+6+2+1+1+2+1+1=15 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2319 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2320 "__\\(END\\|DATA\\)__" ; Commented - does not help with indent...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2321 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2322 ""))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2323 (unwind-protect
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2324 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2325 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2326 (or non-inter
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2327 (message "Scanning for \"hard\" Perl constructions..."))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2328 (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2329 ;; We had evals here, do not know why...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2330 (setq face cperl-pod-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2331 head-face cperl-pod-head-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2332 here-face cperl-here-face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2333 (remove-text-properties min max
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2334 '(syntax-type t in-pod t syntax-table t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2335 ;; Need to remove face as well...
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2336 (goto-char min)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2337 (if (and (eq system-type 'emx)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2338 (looking-at "extproc[ \t]")) ; Analogue of #!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2339 (cperl-commentify min
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2340 (save-excursion (end-of-line) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2341 nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2342 (while (re-search-forward search max t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2343 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2344 ((match-beginning 1) ; POD section
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2345 ;; "\\(\\`\n?\\|\n\n\\)="
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2346 (if (looking-at "\n*cut\\>")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2347 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2348 (message "=cut is not preceded by a POD section")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2349 (or (car err-l) (setcar err-l (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2350 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2351
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2352 (setq b (point) bb b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2353 (or (re-search-forward "\n\n=cut\\>" max 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2354 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2355 (message "End of a POD section not marked by =cut")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2356 (or (car err-l) (setcar err-l b))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2357 (beginning-of-line 2) ; An empty line after =cut is not POD!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2358 (setq e (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2359 (put-text-property b e 'in-pod t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2360 (goto-char b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2361 (while (re-search-forward "\n\n[ \t]" e t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2362 ;; We start 'pod 1 char earlier to include the preceding line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2363 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2364 (put-text-property (cperl-1- b) (point) 'syntax-type 'pod)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2365 (cperl-put-do-not-fontify b (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2366 ;;(put-text-property (max (point-min) (1- b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2367 ;; (point) cperl-do-not-fontify t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2368 (if cperl-pod-here-fontify (put-text-property b (point) 'face face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2369 (re-search-forward "\n\n[^ \t\f\n]" e 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2370 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2371 (setq b (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2372 (put-text-property (cperl-1- (point)) e 'syntax-type 'pod)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2373 (cperl-put-do-not-fontify (point) e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2374 ;;(put-text-property (max (point-min) (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2375 ;; e cperl-do-not-fontify t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2376 (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2377 (progn (put-text-property (point) e 'face face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2378 (goto-char bb)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2379 (if (looking-at
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2380 "=[a-zA-Z0-9_]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2381 (put-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2382 (match-beginning 1) (match-end 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2383 'face head-face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2384 (while (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2385 ;; One paragraph
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2386 "\n\n=[a-zA-Z0-9_]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2387 e 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2388 (put-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2389 (match-beginning 1) (match-end 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2390 'face head-face))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2391 (cperl-commentify bb e nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2392 (goto-char e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2393 (or (eq e (point-max))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2394 (forward-char -1)))) ; Prepare for immediate pod start.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2395 ;; Here document
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2396 ;; We do only one here-per-line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2397 ;; 1 () ahead
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2398 ;; "<<\\(\\([\"'`]\\)\\([^\"'`\n]*\\)\\3\\|\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2399 ((match-beginning 2) ; 1 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2400 ;; Abort in comment:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2401 (setq b (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2402 (setq state (parse-partial-sexp state-point b nil nil state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2403 state-point b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2404 (if ;;(save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2405 ;; (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2406 ;; (search-forward "#" b t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2407 (or (nth 3 state) (nth 4 state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2408 (goto-char (match-end 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2409 (if (match-beginning 5) ;4 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2410 (setq b1 (match-beginning 5) ; 4 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2411 e1 (match-end 5)) ; 4 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2412 (setq b1 (match-beginning 4) ; 3 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2413 e1 (match-end 4))) ; 3 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2414 (setq tag (buffer-substring b1 e1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2415 qtag (regexp-quote tag))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2416 (cond (cperl-pod-here-fontify
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
2417 (put-text-property b1 e1 'face font-lock-constant-face)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2418 (cperl-put-do-not-fontify b1 e1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2419 (forward-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2420 (setq b (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2421 (cond ((re-search-forward (concat "^" qtag "$") max 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2422 (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2423 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2424 (put-text-property (match-beginning 0) (match-end 0)
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
2425 'face font-lock-constant-face)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2426 (cperl-put-do-not-fontify b (match-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2427 ;;(put-text-property (max (point-min) (1- b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2428 ;; (min (point-max)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2429 ;; (1+ (match-end 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2430 ;; cperl-do-not-fontify t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2431 (put-text-property b (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2432 'face here-face)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2433 (setq e1 (cperl-1+ (match-end 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2434 (put-text-property b (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2435 'syntax-type 'here-doc)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2436 (put-text-property (match-beginning 0) e1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2437 'syntax-type 'here-doc-delim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2438 (put-text-property b e1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2439 'here-doc-group t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2440 (cperl-commentify b e1 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2441 (cperl-put-do-not-fontify b (match-end 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2442 (t (message "End of here-document `%s' not found." tag)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2443 (or (car err-l) (setcar err-l b))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2444 ;; format
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2445 ((match-beginning 8)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2446 ;; 1+6=7 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2447 ;;"^[ \t]*\\(format\\)[ \t]*\\([a-zA-Z0-9_]+\\)?[ \t]*=[ \t]*$"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2448 (setq b (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2449 name (if (match-beginning 8) ; 7 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2450 (buffer-substring (match-beginning 8) ; 7 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2451 (match-end 8)) ; 7 + 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2452 ""))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2453 (setq argument nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2454 (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2455 (while (and (eq (forward-line) 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2456 (not (looking-at "^[.;]$")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2457 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2458 ((looking-at "^#")) ; Skip comments
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2459 ((and argument ; Skip argument multi-lines
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2460 (looking-at "^[ \t]*{"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2461 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2462 (setq argument nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2463 (argument ; Skip argument lines
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2464 (setq argument nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2465 (t ; Format line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2466 (setq b1 (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2467 (setq argument (looking-at "^[^\n]*[@^]"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2468 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2469 (put-text-property b1 (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2470 'face font-lock-string-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2471 (cperl-commentify b1 (point) nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2472 (cperl-put-do-not-fontify b1 (point)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2473 (re-search-forward (concat "^[.;]$") max 'toend))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2474 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2475 (if (looking-at "^[.;]$")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2476 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2477 (put-text-property (point) (+ (point) 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2478 'face font-lock-string-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2479 (cperl-commentify (point) (+ (point) 2) nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2480 (cperl-put-do-not-fontify (point) (+ (point) 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2481 (message "End of format `%s' not found." name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2482 (or (car err-l) (setcar err-l b)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2483 (forward-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2484 (put-text-property b (point) 'syntax-type 'format)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2485 ;;; (cond ((re-search-forward (concat "^[.;]$") max 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2486 ;;; (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2487 ;;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2488 ;;; (put-text-property b (match-end 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2489 ;;; 'face font-lock-string-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2490 ;;; (cperl-put-do-not-fontify b (match-end 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2491 ;;; (put-text-property b (match-end 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2492 ;;; 'syntax-type 'format)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2493 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2494 ;;; (t (message "End of format `%s' not found." name)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2495 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2496 ;; Regexp:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2497 ((or (match-beginning 10) (match-beginning 11))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2498 ;; 1+6+2=9 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2499 ;; "\\<\\(q[wxq]?\\|[msy]\\|tr\\)\\>"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2500 ;; "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2501 ;; "\\([?/]\\)" ; /blah/ or ?blah?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2502 (setq b1 (if (match-beginning 10) 10 11)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2503 argument (buffer-substring
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2504 (match-beginning b1) (match-end b1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2505 b (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2506 i b
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2507 c (char-after (match-beginning b1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2508 bb (char-after (1- (match-beginning b1))) ; tmp holder
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2509 bb (and ; user variables/whatever
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2510 (match-beginning 10)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2511 (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2512 (memq bb '(?\$ ?\@ ?\% ?\* ?\#)) ; $#y
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2513 (and (eq bb ?-) (eq c ?s)) ; -s file test
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2514 (and (eq bb ?\&) ; &&m/blah/
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2515 (not (eq (char-after
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2516 (- (match-beginning b1) 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2517 ?\&))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2518 (or bb
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2519 (if (eq b1 11) ; bare /blah/ or ?blah?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2520 (setq argument ""
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2521 bb ; Not a regexp?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2522 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2523 (goto-char (match-beginning b1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2524 (cperl-backward-to-noncomment (point-min))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2525 (not
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2526 ;; What is below: regexp-p?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2527 (and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2528 (or (memq (preceding-char)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2529 (append (if (eq c ?\?)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2530 ;; $a++ ? 1 : 2
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2531 "~{(=|&*!,;"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2532 "~{(=|&+-*!,;") nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2533 (and (eq (preceding-char) ?\})
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2534 (cperl-after-block-p (point-min)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2535 (and (eq (char-syntax (preceding-char)) ?w)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2536 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2537 (forward-sexp -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2538 (looking-at
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2539 "\\(while\\|if\\|unless\\|until\\|and\\|or\\|not\\|xor\\|split\\|grep\\|map\\|print\\)\\>")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2540 (and (eq (preceding-char) ?.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2541 (eq (char-after (- (point) 2)) ?.))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2542 (bobp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2543 ;; m|blah| ? foo : bar;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2544 (not
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2545 (and (eq c ?\?)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2546 cperl-use-syntax-table-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2547 (not (bobp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2548 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2549 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2550 (looking-at "\\s|")))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2551 b (1- b))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2552 (or bb (setq state (parse-partial-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2553 state-point b nil nil state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2554 state-point b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2555 (goto-char b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2556 (if (or bb (nth 3 state) (nth 4 state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2557 (goto-char i)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2558 (if (looking-at "[ \t\n\f]+\\(#[^\n]*\n[ \t\n\f]*\\)+")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2559 (goto-char (match-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2560 (skip-chars-forward " \t\n\f"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2561 ;; qtag means two-arg matcher, may be reset to
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2562 ;; 2 or 3 later if some special quoting is needed.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2563 ;; e1 means matching-char matcher.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2564 (setq b (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2565 i (cperl-forward-re max end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2566 (string-match "^\\([sy]\\|tr\\)$" argument)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2567 t st-l err-l argument)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2568 i2 (nth 1 i) ; start of the second part
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2569 e1 (nth 2 i) ; ender, true if matching second part
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2570 go (nth 4 i) ; There is a 1-char part after the end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2571 i (car i) ; intermediate point
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2572 tail (if (and i (not e1)) (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2573 e nil) ; need to preserve backslashitis
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2574 ;; Commenting \\ is dangerous, what about ( ?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2575 (and i tail
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2576 (eq (char-after i) ?\\)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2577 (setq e t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2578 (if (null i)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2579 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2580 (cperl-commentify b (point) t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2581 (if go (forward-char 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2582 (cperl-commentify b i t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2583 (if (looking-at "\\sw*e") ; s///e
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2584 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2585 (and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2586 ;; silent:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2587 (cperl-find-pods-heres i2 (1- (point)) t end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2588 ;; Error
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2589 (goto-char (1+ max)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2590 (if (and e1 (eq (preceding-char) ?\>))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2591 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2592 (cperl-modify-syntax-type (1- (point)) cperl-st-ket)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2593 (cperl-modify-syntax-type i cperl-st-bra))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2594 (cperl-commentify i2 (point) t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2595 (if e
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2596 (cperl-modify-syntax-type (1+ i) cperl-st-punct))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2597 (setq tail nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2598 (if (eq (char-syntax (following-char)) ?w)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2599 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2600 (forward-word 1) ; skip modifiers s///s
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2601 (if tail (cperl-commentify tail (point) t))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2602 ((match-beginning 13) ; sub with prototypes
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2603 (setq b (match-beginning 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2604 (if (memq (char-after (1- b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2605 '(?\$ ?\@ ?\% ?\& ?\*))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2606 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2607 (setq state (parse-partial-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2608 state-point (1- b) nil nil state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2609 state-point (1- b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2610 (if (or (nth 3 state) (nth 4 state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2611 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2612 ;; Mark as string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2613 (cperl-commentify (match-beginning 13) (match-end 13) t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2614 (goto-char (match-end 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2615 ;; 1+6+2+1+1+2=13 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2616 ;; "\\$\\(['{]\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2617 ((and (match-beginning 14)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2618 (eq (preceding-char) ?\')) ; $'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2619 (setq b (1- (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2620 state (parse-partial-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2621 state-point (1- b) nil nil state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2622 state-point (1- b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2623 (if (nth 3 state) ; in string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2624 (cperl-modify-syntax-type (1- b) cperl-st-punct))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2625 (goto-char (1+ b)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2626 ;; 1+6+2+1+1+2=13 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2627 ;; "\\$\\(['{]\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2628 ((match-beginning 14) ; ${
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2629 (setq bb (match-beginning 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2630 (cperl-modify-syntax-type bb cperl-st-punct))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2631 ;; 1+6+2+1+1+2+1=14 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2632 ;; "\\(\\<sub[ \t\n\f]+\\|[&*$@%]\\)[a-zA-Z0-9_]*'")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2633 ((match-beginning 15) ; old $abc'efg syntax
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2634 (setq bb (match-end 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2635 b (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2636 state (parse-partial-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2637 state-point b nil nil state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2638 state-point b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2639 (if (nth 3 state) ; in string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2640 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2641 (put-text-property (1- bb) bb 'syntax-table cperl-st-word))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2642 (goto-char bb))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2643 ;; 1+6+2+1+1+2+1+1=15 extra () before this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2644 ;; "__\\(END\\|DATA\\)__"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2645 (t ; __END__, __DATA__
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2646 (setq bb (match-end 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2647 b (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2648 state (parse-partial-sexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2649 state-point b nil nil state)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2650 state-point b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2651 (if (or (nth 3 state) (nth 4 state))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2652 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2653 ;; (put-text-property b (1+ bb) 'syntax-type 'pod) ; Cheat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2654 (cperl-commentify b bb nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2655 (setq end t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2656 (goto-char bb)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2657 (if (> (point) max)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2658 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2659 (if end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2660 (message "Garbage after __END__/__DATA__ ignored")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2661 (message "Unbalanced syntax found while scanning")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2662 (or (car err-l) (setcar err-l b)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2663 (goto-char max))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2664 ;;; (while (re-search-forward "\\(\\`\n?\\|\n\n\\)=" max t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2665 ;;; (if (looking-at "\n*cut\\>")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2666 ;;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2667 ;;; (message "=cut is not preceded by a pod section")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2668 ;;; (setq err (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2669 ;;; (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2670
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2671 ;;; (setq b (point) bb b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2672 ;;; (or (re-search-forward "\n\n=cut\\>" max 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2673 ;;; (message "Cannot find the end of a pod section"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2674 ;;; (beginning-of-line 3)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2675 ;;; (setq e (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2676 ;;; (put-text-property b e 'in-pod t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2677 ;;; (goto-char b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2678 ;;; (while (re-search-forward "\n\n[ \t]" e t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2679 ;;; (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2680 ;;; (put-text-property b (point) 'syntax-type 'pod)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2681 ;;; (cperl-put-do-not-fontify b (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2682 ;;; ;;(put-text-property (max (point-min) (1- b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2683 ;;; ;; (point) cperl-do-not-fontify t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2684 ;;; (if cperl-pod-here-fontify (put-text-property b (point) 'face face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2685 ;;; (re-search-forward "\n\n[^ \t\f\n]" e 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2686 ;;; (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2687 ;;; (setq b (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2688 ;;; (put-text-property (point) e 'syntax-type 'pod)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2689 ;;; (cperl-put-do-not-fontify (point) e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2690 ;;; ;;(put-text-property (max (point-min) (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2691 ;;; ;; e cperl-do-not-fontify t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2692 ;;; (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2693 ;;; (progn (put-text-property (point) e 'face face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2694 ;;; (goto-char bb)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2695 ;;; (if (looking-at
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2696 ;;; "=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2697 ;;; (put-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2698 ;;; (match-beginning 1) (match-end 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2699 ;;; 'face head-face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2700 ;;; (while (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2701 ;;; ;; One paragraph
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2702 ;;; "\n\n=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2703 ;;; e 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2704 ;;; (put-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2705 ;;; (match-beginning 1) (match-end 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2706 ;;; 'face head-face))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2707 ;;; (goto-char e)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2708 ;;; (goto-char min)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2709 ;;; (while (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2710 ;;; ;; We exclude \n to avoid misrecognition inside quotes.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2711 ;;; "<<\\(\\([\"'`]\\)\\([^\"'`\n]*\\)\\2\\|\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2712 ;;; max t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2713 ;;; (if (match-beginning 4)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2714 ;;; (setq b1 (match-beginning 4)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2715 ;;; e1 (match-end 4))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2716 ;;; (setq b1 (match-beginning 3)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2717 ;;; e1 (match-end 3)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2718 ;;; (setq tag (buffer-substring b1 e1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2719 ;;; qtag (regexp-quote tag))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2720 ;;; (cond (cperl-pod-here-fontify
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
2721 ;;; (put-text-property b1 e1 'face font-lock-constant-face)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2722 ;;; (cperl-put-do-not-fontify b1 e1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2723 ;;; (forward-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2724 ;;; (setq b (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2725 ;;; (cond ((re-search-forward (concat "^" qtag "$") max 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2726 ;;; (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2727 ;;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2728 ;;; (put-text-property (match-beginning 0) (match-end 0)
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
2729 ;;; 'face font-lock-constant-face)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2730 ;;; (cperl-put-do-not-fontify b (match-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2731 ;;; ;;(put-text-property (max (point-min) (1- b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2732 ;;; ;; (min (point-max)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2733 ;;; ;; (1+ (match-end 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2734 ;;; ;; cperl-do-not-fontify t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2735 ;;; (put-text-property b (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2736 ;;; 'face here-face)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2737 ;;; (put-text-property b (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2738 ;;; 'syntax-type 'here-doc)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2739 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2740 ;;; (t (message "End of here-document `%s' not found." tag))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2741 ;;; (goto-char min)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2742 ;;; (while (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2743 ;;; "^[ \t]*format[ \t]*\\(\\([a-zA-Z0-9_]+[ \t]*\\)?\\)=[ \t]*$"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2744 ;;; max t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2745 ;;; (setq b (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2746 ;;; name (buffer-substring (match-beginning 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2747 ;;; (match-end 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2748 ;;; (cond ((re-search-forward (concat "^[.;]$") max 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2749 ;;; (if cperl-pod-here-fontify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2750 ;;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2751 ;;; (put-text-property b (match-end 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2752 ;;; 'face font-lock-string-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2753 ;;; (cperl-put-do-not-fontify b (match-end 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2754 ;;; (put-text-property b (match-end 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2755 ;;; 'syntax-type 'format)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2756 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2757 ;;; (t (message "End of format `%s' not found." name))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2758 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2759 (if (car err-l) (goto-char (car err-l))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2760 (or noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2761 (message "Scan for \"hard\" Perl constructions completed."))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2762 (and (buffer-modified-p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2763 (not modified)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2764 (set-buffer-modified-p nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2765 (set-syntax-table cperl-mode-syntax-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2766 (car err-l)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2767
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2768 (defun cperl-backward-to-noncomment (lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2769 ;; Stops at lim or after non-whitespace that is not in comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2770 (let (stop p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2771 (while (and (not stop) (> (point) (or lim 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2772 (skip-chars-backward " \t\n\f" lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2773 (setq p (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2774 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2775 (if (or (looking-at "^[ \t]*\\(#\\|$\\)")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2776 (progn (cperl-to-comment-or-eol) (bolp)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2777 nil ; Only comment, skip
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2778 ;; Else
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2779 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2780 (if (< p (point)) (goto-char p))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2781 (setq stop t)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2782
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2783 (defun cperl-after-block-p (lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2784 ;; We suppose that the preceding char is }.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2785 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2786 (condition-case nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2787 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2788 (forward-sexp -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2789 (cperl-backward-to-noncomment lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2790 (or (eq (preceding-char) ?\) ) ; if () {}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2791 (and (eq (char-syntax (preceding-char)) ?w) ; else {}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2792 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2793 (forward-sexp -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2794 (looking-at "\\(else\\|grep\\|map\\)\\>")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2795 (cperl-after-expr-p lim)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2796 (error nil))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2797
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2798 (defun cperl-after-expr-p (&optional lim chars test)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2799 "Returns true if the position is good for start of expression.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2800 TEST is the expression to evaluate at the found position. If absent,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2801 CHARS is a string that contains good characters to have before us (however,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2802 `}' is treated \"smartly\" if it is not in the list)."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2803 (let (stop p
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2804 (lim (or lim (point-min))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2805 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2806 (while (and (not stop) (> (point) lim))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2807 (skip-chars-backward " \t\n\f" lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2808 (setq p (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2809 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2810 (if (looking-at "^[ \t]*\\(#\\|$\\)") nil ; Only comment, skip
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2811 ;; Else: last iteration (What to do with labels?)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2812 (cperl-to-comment-or-eol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2813 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2814 (if (< p (point)) (goto-char p))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2815 (setq stop t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2816 (or (bobp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2817 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2818 (if test (eval test)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2819 (or (memq (preceding-char) (append (or chars "{;") nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2820 (and (eq (preceding-char) ?\})
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2821 (cperl-after-block-p lim)))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2822
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2823 (defun cperl-backward-to-start-of-continued-exp (lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2824 (if (memq (preceding-char) (append ")]}\"'`" nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2825 (forward-sexp -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2826 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2827 (if (<= (point) lim)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2828 (goto-char (1+ lim)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2829 (skip-chars-forward " \t"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2830
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2831
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2832 (defvar innerloop-done nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2833 (defvar last-depth nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2834
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2835 (defun cperl-indent-exp ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2836 "Simple variant of indentation of continued-sexp.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2837 Should be slow. Will not indent comment if it starts at `comment-indent'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2838 or looks like continuation of the comment on the previous line."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2839 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2840 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2841 (let ((tmp-end (progn (end-of-line) (point))) top done)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2842 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2843 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2844 (while (null done)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2845 (setq top (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2846 (while (= (nth 0 (parse-partial-sexp (point) tmp-end
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2847 -1)) -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2848 (setq top (point))) ; Get the outermost parenths in line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2849 (goto-char top)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2850 (while (< (point) tmp-end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2851 (parse-partial-sexp (point) tmp-end nil t) ; To start-sexp or eol
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2852 (or (eolp) (forward-sexp 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2853 (if (> (point) tmp-end) (progn (end-of-line) (setq tmp-end (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2854 (setq done t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2855 (goto-char tmp-end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2856 (setq tmp-end (point-marker)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2857 (cperl-indent-region (point) tmp-end))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2858
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2859 (defun cperl-indent-region (start end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2860 "Simple variant of indentation of region in CPerl mode.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2861 Should be slow. Will not indent comment if it starts at `comment-indent'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2862 or looks like continuation of the comment on the previous line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2863 Indents all the lines whose first character is between START and END
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2864 inclusive."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2865 (interactive "r")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2866 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2867 (let (st comm indent-info old-comm-indent new-comm-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2868 (pm 0) (imenu-scanning-message "Indenting... (%3d%%)"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2869 (goto-char start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2870 (setq old-comm-indent (and (cperl-to-comment-or-eol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2871 (current-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2872 new-comm-indent old-comm-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2873 (goto-char start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2874 (or (bolp) (beginning-of-line 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2875 (or (fboundp 'imenu-progress-message)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2876 (message "Indenting... For feedback load `imenu'..."))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2877 (while (and (<= (point) end) (not (eobp))) ; bol to check start
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2878 (and (fboundp 'imenu-progress-message)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2879 (imenu-progress-message
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2880 pm (/ (* 100 (- (point) start)) (- end start -1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2881 (setq st (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2882 indent-info nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2883 ) ; Believe indentation of the current
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2884 (if (and (setq comm (looking-at "[ \t]*#"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2885 (or (eq (current-indentation) (or old-comm-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2886 comment-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2887 (setq old-comm-indent nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2888 (if (and old-comm-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2889 (= (current-indentation) old-comm-indent)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2890 (not (eq (get-text-property (point) 'syntax-type) 'pod)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2891 (let ((comment-column new-comm-indent))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2892 (indent-for-comment)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2893 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2894 (cperl-indent-line 'indent-info)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2895 (or comm
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2896 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2897 (if (setq old-comm-indent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2898 (and (cperl-to-comment-or-eol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2899 (not (memq (get-text-property (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2900 'syntax-type)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2901 '(pod here-doc)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2902 (current-column)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2903 (progn (indent-for-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2904 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2905 (skip-chars-backward "#")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2906 (setq new-comm-indent (current-column))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2907 (beginning-of-line 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2908 (if (fboundp 'imenu-progress-message)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2909 (imenu-progress-message pm 100)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2910 (message nil)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2911
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2912 ;;(defun cperl-slash-is-regexp (&optional pos)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2913 ;; (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2914 ;; (goto-char (if pos pos (1- (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2915 ;; (and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2916 ;; (not (memq (get-text-property (point) 'face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2917 ;; '(font-lock-string-face font-lock-comment-face)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2918 ;; (cperl-after-expr-p nil nil '
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2919 ;; (or (looking-at "[^]a-zA-Z0-9_)}]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2920 ;; (eq (get-text-property (point) 'face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2921 ;; 'font-lock-keyword-face))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2922
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2923 ;; Stolen from lisp-mode with a lot of improvements
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2924
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2925 (defun cperl-fill-paragraph (&optional justify iteration)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2926 "Like \\[fill-paragraph], but handle CPerl comments.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2927 If any of the current line is a comment, fill the comment or the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2928 block of it that point is in, preserving the comment's initial
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2929 indentation and initial hashes. Behaves usually outside of comment."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2930 (interactive "P")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2931 (let (
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2932 ;; Non-nil if the current line contains a comment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2933 has-comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2934
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2935 ;; If has-comment, the appropriate fill-prefix for the comment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2936 comment-fill-prefix
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2937 ;; Line that contains code and comment (or nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2938 start
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2939 c spaces len dc (comment-column comment-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2940 ;; Figure out what kind of comment we are looking at.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2941 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2942 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2943 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2944
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2945 ;; A line with nothing but a comment on it?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2946 ((looking-at "[ \t]*#[# \t]*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2947 (setq has-comment t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2948 comment-fill-prefix (buffer-substring (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2949 (match-end 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2950
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2951 ;; A line with some code, followed by a comment? Remember that the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2952 ;; semi which starts the comment shouldn't be part of a string or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2953 ;; character.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2954 ((cperl-to-comment-or-eol)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2955 (setq has-comment t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2956 (looking-at "#+[ \t]*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2957 (setq start (point) c (current-column)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2958 comment-fill-prefix
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2959 (concat (make-string (current-column) ?\ )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2960 (buffer-substring (match-beginning 0) (match-end 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2961 spaces (progn (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2962 (buffer-substring (point) start))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2963 dc (- c (current-column)) len (- start (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2964 start (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2965 (delete-char len)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2966 (insert (make-string dc ?-)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2967 (if (not has-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2968 (fill-paragraph justify) ; Do the usual thing outside of comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2969 ;; Narrow to include only the comment, and then fill the region.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2970 (save-restriction
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2971 (narrow-to-region
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2972 ;; Find the first line we should include in the region to fill.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2973 (if start (progn (beginning-of-line) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2974 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2975 (while (and (zerop (forward-line -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2976 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2977 ;; We may have gone to far. Go forward again.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2978 (or (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2979 (forward-line 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2980 (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2981 ;; Find the beginning of the first line past the region to fill.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2982 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2983 (while (progn (forward-line 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2984 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2985 (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2986 ;; Remove existing hashes
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2987 (goto-char (point-min))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2988 (while (progn (forward-line 1) (< (point) (point-max)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2989 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2990 (and (looking-at "#+")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2991 (delete-char (- (match-end 0) (match-beginning 0)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2992
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2993 ;; Lines with only hashes on them can be paragraph boundaries.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2994 (let ((paragraph-start (concat paragraph-start "\\|^[ \t#]*$"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2995 (paragraph-separate (concat paragraph-start "\\|^[ \t#]*$"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2996 (fill-prefix comment-fill-prefix))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2997 (fill-paragraph justify)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2998 (if (and start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2999 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3000 (goto-char start)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3001 (if (> dc 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3002 (progn (delete-char dc) (insert spaces)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3003 (if (or (= (current-column) c) iteration) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3004 (setq comment-column c)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3005 (indent-for-comment)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3006 ;; Repeat once more, flagging as iteration
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3007 (cperl-fill-paragraph justify t)))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3008
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3009 (defun cperl-do-auto-fill ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3010 ;; Break out if the line is short enough
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3011 (if (> (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3012 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3013 (current-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3014 fill-column)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3015 (let ((c (save-excursion (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3016 (cperl-to-comment-or-eol) (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3017 (s (memq (following-char) '(?\ ?\t))) marker)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3018 (if (>= c (point)) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3019 (setq marker (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3020 (cperl-fill-paragraph)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3021 (goto-char marker)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3022 ;; Is not enough, sometimes marker is a start of line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3023 (if (bolp) (progn (re-search-forward "#+[ \t]*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3024 (goto-char (match-end 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3025 ;; Following space could have gone:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3026 (if (or (not s) (memq (following-char) '(?\ ?\t))) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3027 (insert " ")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3028 (backward-char 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3029 ;; Previous space could have gone:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3030 (or (memq (preceding-char) '(?\ ?\t)) (insert " "))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3031
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3032 (defvar imenu-example--function-name-regexp-perl
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3033 (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3034 "^\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3035 "[ \t]*\\(sub\\|package\\)[ \t\n]+\\([a-zA-Z_0-9:']+\\)[ \t]*\\(([^()]*)[ \t]*\\)?"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3036 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3037 "=head\\([12]\\)[ \t]+\\([^\n]+\\)$"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3038 "\\)"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3039
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3040 (defun cperl-imenu-addback (lst &optional isback name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3041 ;; We suppose that the lst is a DAG, unless the first element only
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3042 ;; loops back, and ISBACK is set. Thus this function cannot be
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3043 ;; applied twice without ISBACK set.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3044 (cond ((not cperl-imenu-addback) lst)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3045 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3046 (or name
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3047 (setq name "+++BACK+++"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3048 (mapcar (function (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3049 (if (and (listp elt) (listp (cdr elt)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3050 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3051 ;; In the other order it goes up
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3052 ;; one level only ;-(
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3053 (setcdr elt (cons (cons name lst)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3054 (cdr elt)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3055 (cperl-imenu-addback (cdr elt) t name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3056 ))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3057 (if isback (cdr lst) lst))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3058 lst)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3059
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3060 (defun imenu-example--create-perl-index (&optional regexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3061 (require 'cl)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3062 (require 'imenu) ; May be called from TAGS creator
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3063 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '())
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3064 (index-unsorted-alist '()) (i-s-f (default-value 'imenu-sort-function))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3065 (index-meth-alist '()) meth
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3066 packages ends-ranges p
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3067 (prev-pos 0) char fchar index index1 name (end-range 0) package)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3068 (goto-char (point-min))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3069 (if noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3070 (message "Scanning Perl for index")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3071 (imenu-progress-message prev-pos 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3072 ;; Search for the function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3073 (progn ;;save-match-data
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3074 (while (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3075 (or regexp imenu-example--function-name-regexp-perl)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3076 nil t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3077 (or noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3078 (imenu-progress-message prev-pos))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3079 ;;(backward-up-list 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3080 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3081 ((and ; Skip some noise if building tags
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3082 (match-beginning 2) ; package or sub
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3083 (eq (char-after (match-beginning 2)) ?p) ; package
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3084 (not (save-match-data
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3085 (looking-at "[ \t\n]*;")))) ; Plain text word 'package'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3086 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3087 ((and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3088 (match-beginning 2) ; package or sub
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3089 ;; Skip if quoted (will not skip multi-line ''-comments :-():
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3090 (null (get-text-property (match-beginning 1) 'syntax-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3091 (null (get-text-property (match-beginning 1) 'syntax-type))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3092 (null (get-text-property (match-beginning 1) 'in-pod)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3093 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3094 (goto-char (match-beginning 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3095 (setq fchar (following-char))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3096 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3097 ;; (if (looking-at "([^()]*)[ \t\n\f]*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3098 ;; (goto-char (match-end 0))) ; Messes what follows
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3099 (setq char (following-char)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3100 meth nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3101 p (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3102 (while (and ends-ranges (>= p (car ends-ranges)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3103 ;; delete obsolete entries
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3104 (setq ends-ranges (cdr ends-ranges) packages (cdr packages)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3105 (setq package (or (car packages) "")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3106 end-range (or (car ends-ranges) 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3107 (if (eq fchar ?p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3108 (setq name (buffer-substring (match-beginning 3) (match-end 3))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3109 name (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3110 (set-text-properties 0 (length name) nil name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3111 name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3112 package (concat name "::")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3113 name (concat "package " name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3114 end-range
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3115 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3116 (parse-partial-sexp (point) (point-max) -1) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3117 ends-ranges (cons end-range ends-ranges)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3118 packages (cons package packages)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3119 ;; )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3120 ;; Skip this function name if it is a prototype declaration.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3121 (if (and (eq fchar ?s) (eq char ?\;)) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3122 (setq index (imenu-example--name-and-position))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3123 (if (eq fchar ?p) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3124 (setq name (buffer-substring (match-beginning 3) (match-end 3)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3125 (set-text-properties 0 (length name) nil name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3126 (cond ((string-match "[:']" name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3127 (setq meth t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3128 ((> p end-range) nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3129 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3130 (setq name (concat package name) meth t))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3131 (setcar index name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3132 (if (eq fchar ?p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3133 (push index index-pack-alist)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3134 (push index index-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3135 (if meth (push index index-meth-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3136 (push index index-unsorted-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3137 ((match-beginning 5) ; Pod section
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3138 ;; (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3139 (setq index (imenu-example--name-and-position)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3140 name (buffer-substring (match-beginning 6) (match-end 6)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3141 (set-text-properties 0 (length name) nil name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3142 (if (eq (char-after (match-beginning 5)) ?2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3143 (setq name (concat " " name)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3144 (setcar index name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3145 (setq index1 (cons (concat "=" name) (cdr index)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3146 (push index index-pod-alist)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3147 (push index1 index-unsorted-alist)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3148 (or noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3149 (imenu-progress-message prev-pos 100))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3150 (setq index-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3151 (if (default-value 'imenu-sort-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3152 (sort index-alist (default-value 'imenu-sort-function))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3153 (nreverse index-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3154 (and index-pod-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3155 (push (cons "+POD headers+..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3156 (nreverse index-pod-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3157 index-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3158 (and (or index-pack-alist index-meth-alist)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3159 (let ((lst index-pack-alist) hier-list pack elt group name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3160 ;; Remove "package ", reverse and uniquify.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3161 (while lst
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3162 (setq elt (car lst) lst (cdr lst) name (substring (car elt) 8))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3163 (if (assoc name hier-list) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3164 (setq hier-list (cons (cons name (cdr elt)) hier-list))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3165 (setq lst index-meth-alist)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3166 (while lst
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3167 (setq elt (car lst) lst (cdr lst))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3168 (cond ((string-match "\\(::\\|'\\)[_a-zA-Z0-9]+$" (car elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3169 (setq pack (substring (car elt) 0 (match-beginning 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3170 (if (setq group (assoc pack hier-list))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3171 (if (listp (cdr group))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3172 ;; Have some functions already
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3173 (setcdr group
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3174 (cons (cons (substring
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3175 (car elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3176 (+ 2 (match-beginning 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3177 (cdr elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3178 (cdr group)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3179 (setcdr group (list (cons (substring
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3180 (car elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3181 (+ 2 (match-beginning 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3182 (cdr elt)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3183 (setq hier-list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3184 (cons (cons pack
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3185 (list (cons (substring
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3186 (car elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3187 (+ 2 (match-beginning 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3188 (cdr elt))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3189 hier-list))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3190 (push (cons "+Hierarchy+..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3191 hier-list)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3192 index-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3193 (and index-pack-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3194 (push (cons "+Packages+..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3195 (nreverse index-pack-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3196 index-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3197 (and (or index-pack-alist index-pod-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3198 (default-value 'imenu-sort-function))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3199 index-unsorted-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3200 (push (cons "+Unsorted List+..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3201 (nreverse index-unsorted-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3202 index-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3203 (cperl-imenu-addback index-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3204
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3205 (defvar cperl-compilation-error-regexp-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3206 ;; This look like a paranoiac regexp: could anybody find a better one? (which WORK).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3207 '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\., \n]"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3208 2 3))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3209 "Alist that specifies how to match errors in perl output.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3210
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3211 (if (fboundp 'eval-after-load)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3212 (eval-after-load
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3213 "mode-compile"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3214 '(setq perl-compilation-error-regexp-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3215 cperl-compilation-error-regexp-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3216
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3217
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3218 (defvar cperl-faces-init nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3219
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3220 (defun cperl-windowed-init ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3221 "Initialization under windowed version."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3222 (add-hook 'font-lock-mode-hook
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3223 (function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3224 (lambda ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3225 (if (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3226 (eq major-mode 'perl-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3227 (eq major-mode 'cperl-mode))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3228 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3229 (or cperl-faces-init (cperl-init-faces))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3230
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3231 (defvar perl-font-lock-keywords-1 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3232 "Additional expressions to highlight in Perl mode. Minimal set.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3233 (defvar perl-font-lock-keywords nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3234 "Additional expressions to highlight in Perl mode. Default set.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3235 (defvar perl-font-lock-keywords-2 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3236 "Additional expressions to highlight in Perl mode. Maximal set")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3237
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3238 (defun cperl-init-faces ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3239 (condition-case nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3240 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3241 (require 'font-lock)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3242 (and (fboundp 'font-lock-fontify-anchored-keywords)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3243 (featurep 'font-lock-extra)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3244 (message "You have an obsolete package `font-lock-extra'. Install `choose-color'."))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3245 (let (t-font-lock-keywords t-font-lock-keywords-1 font-lock-anchored)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3246 ;;(defvar cperl-font-lock-enhanced nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3247 ;; "Set to be non-nil if font-lock allows active highlights.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3248 (if (fboundp 'font-lock-fontify-anchored-keywords)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3249 (setq font-lock-anchored t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3250 (setq
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3251 t-font-lock-keywords
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3252 (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3253 (cons
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3254 (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3255 "\\(^\\|[^$@%&\\]\\)\\<\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3256 (mapconcat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3257 'identity
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3258 '("if" "until" "while" "elsif" "else" "unless" "for"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3259 "foreach" "continue" "exit" "die" "last" "goto" "next"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3260 "redo" "return" "local" "exec" "sub" "do" "dump" "use"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3261 "require" "package" "eval" "my" "BEGIN" "END")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3262 "\\|") ; Flow control
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3263 "\\)\\>") 2) ; was "\\)[ \n\t;():,\|&]"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3264 ; In what follows we use `type' style
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3265 ; for overwritable builtins
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3266 (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3267 (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3268 "\\(^\\|[^$@%&\\]\\)\\<\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3269 ;; "CORE" "__FILE__" "__LINE__" "abs" "accept" "alarm"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3270 ;; "and" "atan2" "bind" "binmode" "bless" "caller"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3271 ;; "chdir" "chmod" "chown" "chr" "chroot" "close"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3272 ;; "closedir" "cmp" "connect" "continue" "cos" "crypt"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3273 ;; "dbmclose" "dbmopen" "die" "dump" "endgrent"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3274 ;; "endhostent" "endnetent" "endprotoent" "endpwent"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3275 ;; "endservent" "eof" "eq" "exec" "exit" "exp" "fcntl"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3276 ;; "fileno" "flock" "fork" "formline" "ge" "getc"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3277 ;; "getgrent" "getgrgid" "getgrnam" "gethostbyaddr"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3278 ;; "gethostbyname" "gethostent" "getlogin"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3279 ;; "getnetbyaddr" "getnetbyname" "getnetent"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3280 ;; "getpeername" "getpgrp" "getppid" "getpriority"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3281 ;; "getprotobyname" "getprotobynumber" "getprotoent"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3282 ;; "getpwent" "getpwnam" "getpwuid" "getservbyname"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3283 ;; "getservbyport" "getservent" "getsockname"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3284 ;; "getsockopt" "glob" "gmtime" "gt" "hex" "index" "int"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3285 ;; "ioctl" "join" "kill" "lc" "lcfirst" "le" "length"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3286 ;; "link" "listen" "localtime" "log" "lstat" "lt"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3287 ;; "mkdir" "msgctl" "msgget" "msgrcv" "msgsnd" "ne"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3288 ;; "not" "oct" "open" "opendir" "or" "ord" "pack" "pipe"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3289 ;; "quotemeta" "rand" "read" "readdir" "readline"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3290 ;; "readlink" "readpipe" "recv" "ref" "rename" "require"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3291 ;; "reset" "reverse" "rewinddir" "rindex" "rmdir" "seek"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3292 ;; "seekdir" "select" "semctl" "semget" "semop" "send"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3293 ;; "setgrent" "sethostent" "setnetent" "setpgrp"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3294 ;; "setpriority" "setprotoent" "setpwent" "setservent"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3295 ;; "setsockopt" "shmctl" "shmget" "shmread" "shmwrite"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3296 ;; "shutdown" "sin" "sleep" "socket" "socketpair"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3297 ;; "sprintf" "sqrt" "srand" "stat" "substr" "symlink"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3298 ;; "syscall" "sysread" "system" "syswrite" "tell"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3299 ;; "telldir" "time" "times" "truncate" "uc" "ucfirst"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3300 ;; "umask" "unlink" "unpack" "utime" "values" "vec"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3301 ;; "wait" "waitpid" "wantarray" "warn" "write" "x" "xor"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3302 "a\\(bs\\|ccept\\|tan2\\|larm\\|nd\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3303 "b\\(in\\(d\\|mode\\)\\|less\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3304 "c\\(h\\(r\\(\\|oot\\)\\|dir\\|mod\\|own\\)\\|aller\\|rypt\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3305 "lose\\(\\|dir\\)\\|mp\\|o\\(s\\|n\\(tinue\\|nect\\)\\)\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3306 "CORE\\|d\\(ie\\|bm\\(close\\|open\\)\\|ump\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3307 "e\\(x\\(p\\|it\\|ec\\)\\|q\\|nd\\(p\\(rotoent\\|went\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3308 "hostent\\|servent\\|netent\\|grent\\)\\|of\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3309 "f\\(ileno\\|cntl\\|lock\\|or\\(k\\|mline\\)\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3310 "g\\(t\\|lob\\|mtime\\|e\\(\\|t\\(p\\(pid\\|r\\(iority\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3311 "oto\\(byn\\(ame\\|umber\\)\\|ent\\)\\)\\|eername\\|w"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3312 "\\(uid\\|ent\\|nam\\)\\|grp\\)\\|host\\(by\\(addr\\|name\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3313 "ent\\)\\|s\\(erv\\(by\\(port\\|name\\)\\|ent\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3314 "ock\\(name\\|opt\\)\\)\\|c\\|login\\|net\\(by\\(addr\\|name\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3315 "ent\\)\\|gr\\(ent\\|nam\\|gid\\)\\)\\)\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3316 "hex\\|i\\(n\\(t\\|dex\\)\\|octl\\)\\|join\\|kill\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3317 "l\\(i\\(sten\\|nk\\)\\|stat\\|c\\(\\|first\\)\\|t\\|e"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3318 "\\(\\|ngth\\)\\|o\\(caltime\\|g\\)\\)\\|m\\(sg\\(rcv\\|snd\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3319 "ctl\\|get\\)\\|kdir\\)\\|n\\(e\\|ot\\)\\|o\\(pen\\(\\|dir\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3320 "r\\(\\|d\\)\\|ct\\)\\|p\\(ipe\\|ack\\)\\|quotemeta\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3321 "r\\(index\\|and\\|mdir\\|e\\(quire\\|ad\\(pipe\\|\\|lin"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3322 "\\(k\\|e\\)\\|dir\\)\\|set\\|cv\\|verse\\|f\\|winddir\\|name"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3323 "\\)\\)\\|s\\(printf\\|qrt\\|rand\\|tat\\|ubstr\\|e\\(t\\(p\\(r"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3324 "\\(iority\\|otoent\\)\\|went\\|grp\\)\\|hostent\\|s\\(ervent\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3325 "ockopt\\)\\|netent\\|grent\\)\\|ek\\(\\|dir\\)\\|lect\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3326 "m\\(ctl\\|op\\|get\\)\\|nd\\)\\|h\\(utdown\\|m\\(read\\|ctl\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3327 "write\\|get\\)\\)\\|y\\(s\\(read\\|call\\|tem\\|write\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3328 "mlink\\)\\|in\\|leep\\|ocket\\(pair\\|\\)\\)\\|t\\(runcate\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3329 "ell\\(\\|dir\\)\\|ime\\(\\|s\\)\\)\\|u\\(c\\(\\|first\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3330 "time\\|mask\\|n\\(pack\\|link\\)\\)\\|v\\(alues\\|ec\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3331 "w\\(a\\(rn\\|it\\(pid\\|\\)\\|ntarray\\)\\|rite\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3332 "x\\(\\|or\\)\\|__\\(FILE__\\|LINE__\\|PACKAGE__\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3333 "\\)\\>") 2 'font-lock-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3334 ;; In what follows we use `other' style
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3335 ;; for nonoverwritable builtins
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3336 ;; Somehow 's', 'm' are not auto-generated???
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3337 (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3338 (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3339 "\\(^\\|[^$@%&\\]\\)\\<\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3340 ;; "AUTOLOAD" "BEGIN" "DESTROY" "END" "__END__" "chomp"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3341 ;; "chop" "defined" "delete" "do" "each" "else" "elsif"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3342 ;; "eval" "exists" "for" "foreach" "format" "goto"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3343 ;; "grep" "if" "keys" "last" "local" "map" "my" "next"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3344 ;; "no" "package" "pop" "pos" "print" "printf" "push"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3345 ;; "q" "qq" "qw" "qx" "redo" "return" "scalar" "shift"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3346 ;; "sort" "splice" "split" "study" "sub" "tie" "tr"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3347 ;; "undef" "unless" "unshift" "untie" "until" "use"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3348 ;; "while" "y"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3349 "AUTOLOAD\\|BEGIN\\|cho\\(p\\|mp\\)\\|d\\(e\\(fined\\|lete\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3350 "o\\)\\|DESTROY\\|e\\(ach\\|val\\|xists\\|ls\\(e\\|if\\)\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3351 "END\\|for\\(\\|each\\|mat\\)\\|g\\(rep\\|oto\\)\\|if\\|keys\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3352 "l\\(ast\\|ocal\\)\\|m\\(ap\\|y\\)\\|n\\(ext\\|o\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3353 "p\\(ackage\\|rint\\(\\|f\\)\\|ush\\|o\\(p\\|s\\)\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3354 "q\\(\\|q\\|w\\|x\\)\\|re\\(turn\\|do\\)\\|s\\(pli\\(ce\\|t\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3355 "calar\\|tudy\\|ub\\|hift\\|ort\\)\\|t\\(r\\|ie\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3356 "u\\(se\\|n\\(shift\\|ti\\(l\\|e\\)\\|def\\|less\\)\\)\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3357 "while\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3358 "\\|[sm]" ; Added manually
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3359 "\\)\\>") 2 'font-lock-other-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3360 ;; (mapconcat 'identity
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3361 ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3362 ;; "#include" "#define" "#undef")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3363 ;; "\\|")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3364 '("-[rwxoRWXOezsfdlpSbctugkTBMAC]\\>\\([ \t]+_\\>\\)?" 0
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3365 font-lock-function-name-face keep) ; Not very good, triggers at "[a-z]"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3366 '("\\<sub[ \t]+\\([^ \t{;]+\\)[ \t]*\\(([^()]*)[ \t]*\\)?[#{\n]" 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3367 font-lock-function-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3368 '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\)[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t;]" ; require A if B;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3369 2 font-lock-function-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3370 '("^[ \t]*format[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t]*=[ \t]*$"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3371 1 font-lock-function-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3372 (cond ((featurep 'font-lock-extra)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3373 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3374 (2 font-lock-string-face t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3375 (0 '(restart 2 t)))) ; To highlight $a{bc}{ef}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3376 (font-lock-anchored
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3377 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3378 (2 font-lock-string-face t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3379 ("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3380 nil nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3381 (1 font-lock-string-face t))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3382 (t '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3383 2 font-lock-string-face t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3384 '("[ \t{,(]\\(-?[a-zA-Z0-9_:]+\\)[ \t]*=>" 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3385 font-lock-string-face t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3386 '("^[ \t]*\\([a-zA-Z0-9_]+[ \t]*:\\)[ \t]*\\($\\|{\\|\\<\\(until\\|while\\|for\\(each\\)?\\|do\\)\\>\\)" 1
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
3387 font-lock-constant-face) ; labels
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3388 '("\\<\\(continue\\|next\\|last\\|redo\\|goto\\)\\>[ \t]+\\([a-zA-Z0-9_:]+\\)" ; labels as targets
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
3389 2 font-lock-constant-face)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3390 (cond ((featurep 'font-lock-extra)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3391 '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3392 (3 font-lock-variable-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3393 (4 '(another 4 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3394 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3395 (1 font-lock-variable-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3396 (2 '(restart 2 nil) nil t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3397 nil t))) ; local variables, multiple
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3398 (font-lock-anchored
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3399 '("^[ \t{}]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3400 (3 font-lock-variable-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3401 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3402 nil nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3403 (1 font-lock-variable-name-face))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3404 (t '("^[ \t{}]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3405 3 font-lock-variable-name-face)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3406 '("\\<for\\(each\\)?[ \t]*\\(\\$[a-zA-Z_][a-zA-Z_0-9]*\\)[ \t]*("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3407 2 font-lock-variable-name-face)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3408 (setq
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3409 t-font-lock-keywords-1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3410 (and (fboundp 'turn-on-font-lock) ; Check for newer font-lock
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3411 (not cperl-xemacs-p) ; not yet as of XEmacs 19.12
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3412 '(
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3413 ("\\(\\([@%]\\|\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3414 (if (eq (char-after (match-beginning 2)) ?%)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3415 font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3416 font-lock-emphasized-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3417 t) ; arrays and hashes
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3418 ("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3419 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3420 (if (= (- (match-end 2) (match-beginning 2)) 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3421 (if (eq (char-after (match-beginning 3)) ?{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3422 font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3423 font-lock-emphasized-face) ; arrays and hashes
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3424 font-lock-variable-name-face) ; Just to put something
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3425 t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3426 ;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3427 ;;; Too much noise from \s* @s[ and friends
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3428 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3429 ;;(3 font-lock-function-name-face t t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3430 ;;(4
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3431 ;; (if (cperl-slash-is-regexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3432 ;; font-lock-function-name-face 'default) nil t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3433 )))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3434 (setq perl-font-lock-keywords-1 t-font-lock-keywords
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3435 perl-font-lock-keywords perl-font-lock-keywords-1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3436 perl-font-lock-keywords-2 (append
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3437 t-font-lock-keywords
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3438 t-font-lock-keywords-1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3439 (if (fboundp 'ps-print-buffer) (cperl-ps-print-init))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3440 (if (or (featurep 'choose-color) (featurep 'font-lock-extra))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3441 (font-lock-require-faces
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3442 (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3443 ;; Color-light Color-dark Gray-light Gray-dark Mono
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3444 (list 'font-lock-comment-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3445 ["Firebrick" "OrangeRed" "DimGray" "Gray80"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3446 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3447 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3448 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3449 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3450 (list 'font-lock-string-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3451 ["RosyBrown" "LightSalmon" "Gray50" "LightGray"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3452 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3453 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3454 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3455 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3456 (list 'font-lock-keyword-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3457 ["Purple" "LightSteelBlue" "DimGray" "Gray90"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3458 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3459 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3460 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3461 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3462 (list 'font-lock-function-name-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3463 (vector
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3464 "Blue" "LightSkyBlue" "Gray50" "LightGray"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3465 (cdr (assq 'background-color ; if mono
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3466 (frame-parameters))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3467 (vector
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3468 nil nil nil nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3469 (cdr (assq 'foreground-color ; if mono
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3470 (frame-parameters))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3471 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3472 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3473 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3474 (list 'font-lock-variable-name-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3475 ["DarkGoldenrod" "LightGoldenrod" "DimGray" "Gray90"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3476 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3477 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3478 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3479 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3480 (list 'font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3481 ["DarkOliveGreen" "PaleGreen" "DimGray" "Gray80"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3482 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3483 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3484 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3485 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3486 )
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
3487 (list 'font-lock-constant-face
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3488 ["CadetBlue" "Aquamarine" "Gray50" "LightGray"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3489 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3490 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3491 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3492 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3493 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3494 (list 'font-lock-other-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3495 ["chartreuse3" ("orchid1" "orange")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3496 nil "Gray80"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3497 [nil nil "gray90"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3498 [nil nil nil t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3499 [nil nil t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3500 [nil nil t t t]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3501 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3502 (list 'font-lock-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3503 ["blue" "yellow" nil "Gray80"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3504 ["lightyellow2" ("navy" "os2blue" "darkgreen")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3505 "gray90"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3506 t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3507 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3508 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3509 (list 'font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3510 ["red" "red" nil "Gray80"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3511 ["lightyellow2" ("navy" "os2blue" "darkgreen")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3512 "gray90"]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3513 t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3514 t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3515 nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3516 (defvar cperl-guessed-background nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3517 "Display characteristics as guessed by cperl.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3518 (or (fboundp 'x-color-defined-p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3519 (defalias 'x-color-defined-p
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3520 (cond ((fboundp 'color-defined-p) 'color-defined-p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3521 ;; XEmacs >= 19.12
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3522 ((fboundp 'valid-color-name-p) 'valid-color-name-p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3523 ;; XEmacs 19.11
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3524 (t 'x-valid-color-name-p))))
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
3525 (defvar font-lock-constant-face 'font-lock-constant-face)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3526 (defvar font-lock-variable-name-face 'font-lock-variable-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3527 (or (boundp 'font-lock-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3528 (defconst font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3529 'font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3530 "Face to use for data types.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3531 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3532 (or (boundp 'font-lock-other-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3533 (defconst font-lock-other-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3534 'font-lock-other-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3535 "Face to use for data types from another group.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3536 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3537 (if (not cperl-xemacs-p) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3538 (or (boundp 'font-lock-comment-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3539 (defconst font-lock-comment-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3540 'font-lock-comment-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3541 "Face to use for comments.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3542 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3543 (or (boundp 'font-lock-keyword-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3544 (defconst font-lock-keyword-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3545 'font-lock-keyword-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3546 "Face to use for keywords.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3547 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3548 (or (boundp 'font-lock-function-name-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3549 (defconst font-lock-function-name-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3550 'font-lock-function-name-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3551 "Face to use for function names.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3552 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3553 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3554 ;;(if (featurep 'font-lock)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3555 (if (face-equal font-lock-type-face font-lock-comment-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3556 (defconst font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3557 'font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3558 "Face to use for basic data types.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3559 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3560 ;;; (if (fboundp 'eval-after-load)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3561 ;;; (eval-after-load "font-lock"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3562 ;;; '(if (face-equal font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3563 ;;; font-lock-comment-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3564 ;;; (defconst font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3565 ;;; 'font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3566 ;;; "Face to use for basic data types.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3567 ;;; ))) ; This does not work :-( Why?!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3568 ;;; ; Workaround: added to font-lock-m-h
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3569 ;;; )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3570 (or (boundp 'font-lock-other-emphasized-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3571 (defconst font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3572 'font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3573 "Face to use for another type of emphasizing.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3574 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3575 (or (boundp 'font-lock-emphasized-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3576 (defconst font-lock-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3577 'font-lock-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3578 "Face to use for emphasizing.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3579 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3580 ;; Here we try to guess background
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3581 (let ((background
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3582 (if (boundp 'font-lock-background-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3583 font-lock-background-mode
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3584 'light))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3585 (face-list (and (fboundp 'face-list) (face-list)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3586 is-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3587 (fset 'is-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3588 (cond ((fboundp 'find-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3589 (symbol-function 'find-face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3590 (face-list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3591 (function (lambda (face) (member face face-list))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3592 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3593 (function (lambda (face) (boundp face))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3594 (defvar cperl-guessed-background
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3595 (if (and (boundp 'font-lock-display-type)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3596 (eq font-lock-display-type 'grayscale))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3597 'gray
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3598 background)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3599 "Background as guessed by CPerl mode")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3600 (if (is-face 'font-lock-type-face) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3601 (copy-face 'default 'font-lock-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3602 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3603 ((eq background 'light)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3604 (set-face-foreground 'font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3605 (if (x-color-defined-p "seagreen")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3606 "seagreen"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3607 "sea green")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3608 ((eq background 'dark)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3609 (set-face-foreground 'font-lock-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3610 (if (x-color-defined-p "os2pink")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3611 "os2pink"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3612 "pink")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3613 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3614 (set-face-background 'font-lock-type-face "gray90"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3615 (if (is-face 'font-lock-other-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3616 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3617 (copy-face 'font-lock-type-face 'font-lock-other-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3618 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3619 ((eq background 'light)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3620 (set-face-foreground 'font-lock-other-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3621 (if (x-color-defined-p "chartreuse3")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3622 "chartreuse3"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3623 "chartreuse")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3624 ((eq background 'dark)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3625 (set-face-foreground 'font-lock-other-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3626 (if (x-color-defined-p "orchid1")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3627 "orchid1"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3628 "orange")))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3629 (if (is-face 'font-lock-other-emphasized-face) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3630 (copy-face 'bold-italic 'font-lock-other-emphasized-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3631 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3632 ((eq background 'light)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3633 (set-face-background 'font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3634 (if (x-color-defined-p "lightyellow2")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3635 "lightyellow2"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3636 (if (x-color-defined-p "lightyellow")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3637 "lightyellow"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3638 "light yellow"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3639 ((eq background 'dark)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3640 (set-face-background 'font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3641 (if (x-color-defined-p "navy")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3642 "navy"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3643 (if (x-color-defined-p "darkgreen")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3644 "darkgreen"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3645 "dark green"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3646 (t (set-face-background 'font-lock-other-emphasized-face "gray90"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3647 (if (is-face 'font-lock-emphasized-face) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3648 (copy-face 'bold 'font-lock-emphasized-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3649 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3650 ((eq background 'light)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3651 (set-face-background 'font-lock-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3652 (if (x-color-defined-p "lightyellow2")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3653 "lightyellow2"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3654 "lightyellow")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3655 ((eq background 'dark)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3656 (set-face-background 'font-lock-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3657 (if (x-color-defined-p "navy")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3658 "navy"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3659 (if (x-color-defined-p "darkgreen")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3660 "darkgreen"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3661 "dark green"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3662 (t (set-face-background 'font-lock-emphasized-face "gray90"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3663 (if (is-face 'font-lock-variable-name-face) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3664 (copy-face 'italic 'font-lock-variable-name-face))
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
3665 (if (is-face 'font-lock-constant-face) nil
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20323
diff changeset
3666 (copy-face 'italic 'font-lock-constant-face))))
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3667 (setq cperl-faces-init t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3668 (error nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3669
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3670
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3671 (defun cperl-ps-print-init ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3672 "Initialization of `ps-print' components for faces used in CPerl."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3673 ;; Guard against old versions
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3674 (defvar ps-underlined-faces nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3675 (defvar ps-bold-faces nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3676 (defvar ps-italic-faces nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3677 (setq ps-bold-faces
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3678 (append '(font-lock-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3679 font-lock-keyword-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3680 font-lock-variable-name-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3681 font-lock-reference-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3682 font-lock-other-emphasized-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3683 ps-bold-faces))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3684 (setq ps-italic-faces
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3685 (append '(font-lock-other-type-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3686 font-lock-reference-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3687 font-lock-other-emphasized-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3688 ps-italic-faces))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3689 (setq ps-underlined-faces
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3690 (append '(font-lock-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3691 font-lock-other-emphasized-face
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3692 font-lock-other-type-face font-lock-type-face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3693 ps-underlined-faces))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3694 (cons 'font-lock-type-face ps-underlined-faces))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3695
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3696
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3697 (if (cperl-enable-font-lock) (cperl-windowed-init))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3698
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3699 (defun cperl-set-style (style)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3700 "Set CPerl-mode variables to use one of several different indentation styles.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3701 The arguments are a string representing the desired style.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3702 Available styles are GNU, K&R, BSD and Whitesmith."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3703 (interactive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3704 (let ((list (mapcar (function (lambda (elt) (list (car elt))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3705 c-style-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3706 (list (completing-read "Enter style: " list nil 'insist))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3707 (let ((style (cdr (assoc style c-style-alist))) setting str sym)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3708 (while style
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3709 (setq setting (car style) style (cdr style))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3710 (setq str (symbol-name (car setting)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3711 (and (string-match "^c-" str)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3712 (setq str (concat "cperl-" (substring str 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3713 (setq sym (intern-soft str))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3714 (boundp sym)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3715 (set sym (cdr setting))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3716
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3717 (defun cperl-check-syntax ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3718 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3719 (require 'mode-compile)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3720 (let ((perl-dbg-flags "-wc"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3721 (mode-compile)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3722
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3723 (defun cperl-info-buffer (type)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3724 ;; Returns buffer with documentation. Creates if missing.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3725 ;; If TYPE, this vars buffer.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3726 ;; Special care is taken to not stomp over an existing info buffer
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3727 (let* ((bname (if type "*info-perl-var*" "*info-perl*"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3728 (info (get-buffer bname))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3729 (oldbuf (get-buffer "*info*")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3730 (if info info
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3731 (save-window-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3732 ;; Get Info running
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3733 (require 'info)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3734 (cond (oldbuf
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3735 (set-buffer oldbuf)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3736 (rename-buffer "*info-perl-tmp*")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3737 (save-window-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3738 (info))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3739 (Info-find-node cperl-info-page (if type "perlvar" "perlfunc"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3740 (set-buffer "*info*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3741 (rename-buffer bname)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3742 (cond (oldbuf
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3743 (set-buffer "*info-perl-tmp*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3744 (rename-buffer "*info*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3745 (set-buffer bname)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3746 (make-variable-buffer-local 'window-min-height)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3747 (setq window-min-height 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3748 (current-buffer)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3749
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3750 (defun cperl-word-at-point (&optional p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3751 ;; Returns the word at point or at P.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3752 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3753 (if p (goto-char p))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3754 (or (cperl-word-at-point-hard)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3755 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3756 (require 'etags)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3757 (funcall (or (and (boundp 'find-tag-default-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3758 find-tag-default-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3759 (get major-mode 'find-tag-default-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3760 ;; XEmacs 19.12 has `find-tag-default-hook'; it is
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3761 ;; automatically used within `find-tag-default':
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3762 'find-tag-default))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3763
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3764 (defun cperl-info-on-command (command)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3765 "Shows documentation for Perl command in other window.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3766 If perl-info buffer is shown in some frame, uses this frame.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3767 Customized by setting variables `cperl-shrink-wrap-info-frame',
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3768 `cperl-max-help-size'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3769 (interactive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3770 (let* ((default (cperl-word-at-point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3771 (read (read-string
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3772 (format "Find doc for Perl function (default %s): "
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3773 default))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3774 (list (if (equal read "")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3775 default
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3776 read))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3777
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3778 (let ((buffer (current-buffer))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3779 (cmd-desc (concat "^" (regexp-quote command) "[^a-zA-Z_0-9]")) ; "tr///"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3780 pos isvar height iniheight frheight buf win fr1 fr2 iniwin not-loner
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3781 max-height char-height buf-list)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3782 (if (string-match "^-[a-zA-Z]$" command)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3783 (setq cmd-desc "^-X[ \t\n]"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3784 (setq isvar (string-match "^[$@%]" command)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3785 buf (cperl-info-buffer isvar)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3786 iniwin (selected-window)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3787 fr1 (window-frame iniwin))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3788 (set-buffer buf)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3789 (beginning-of-buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3790 (or isvar
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3791 (progn (re-search-forward "^-X[ \t\n]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3792 (forward-line -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3793 (if (re-search-forward cmd-desc nil t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3794 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3795 ;; Go back to beginning of the group (ex, for qq)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3796 (if (re-search-backward "^[ \t\n\f]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3797 (forward-line 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3798 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3799 ;; Get some of
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3800 (setq pos (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3801 buf-list (list buf "*info-perl-var*" "*info-perl*"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3802 (while (and (not win) buf-list)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3803 (setq win (get-buffer-window (car buf-list) t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3804 (setq buf-list (cdr buf-list)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3805 (or (not win)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3806 (eq (window-buffer win) buf)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3807 (set-window-buffer win buf))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3808 (and win (setq fr2 (window-frame win)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3809 (if (or (not fr2) (eq fr1 fr2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3810 (pop-to-buffer buf)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3811 (special-display-popup-frame buf) ; Make it visible
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3812 (select-window win))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3813 (goto-char pos) ; Needed (?!).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3814 ;; Resize
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3815 (setq iniheight (window-height)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3816 frheight (frame-height)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3817 not-loner (< iniheight (1- frheight))) ; Are not alone
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3818 (cond ((if not-loner cperl-max-help-size
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3819 cperl-shrink-wrap-info-frame)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3820 (setq height
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3821 (+ 2
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3822 (count-lines
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3823 pos
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3824 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3825 (if (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3826 "^[ \t][^\n]*\n+\\([^ \t\n\f]\\|\\'\\)" nil t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3827 (match-beginning 0) (point-max)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3828 max-height
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3829 (if not-loner
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3830 (/ (* (- frheight 3) cperl-max-help-size) 100)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3831 (setq char-height (frame-char-height))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3832 ;; Non-functioning under OS/2:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3833 (if (eq char-height 1) (setq char-height 18))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3834 ;; Title, menubar, + 2 for slack
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3835 (- (/ (x-display-pixel-height) char-height) 4)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3836 ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3837 (if (> height max-height) (setq height max-height))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3838 ;;(message "was %s doing %s" iniheight height)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3839 (if not-loner
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3840 (enlarge-window (- height iniheight))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3841 (set-frame-height (window-frame win) (1+ height)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3842 (set-window-start (selected-window) pos))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3843 (message "No entry for %s found." command))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3844 ;;(pop-to-buffer buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3845 (select-window iniwin)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3846
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3847 (defun cperl-info-on-current-command ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3848 "Shows documentation for Perl command at point in other window."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3849 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3850 (cperl-info-on-command (cperl-word-at-point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3851
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3852 (defun cperl-imenu-info-imenu-search ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3853 (if (looking-at "^-X[ \t\n]") nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3854 (re-search-backward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3855 "^\n\\([-a-zA-Z_]+\\)[ \t\n]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3856 (forward-line 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3857
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3858 (defun cperl-imenu-info-imenu-name ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3859 (buffer-substring
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3860 (match-beginning 1) (match-end 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3861
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3862 (defun cperl-imenu-on-info ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3863 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3864 (let* ((buffer (current-buffer))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3865 imenu-create-index-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3866 imenu-prev-index-position-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3867 imenu-extract-index-name-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3868 (index-item (save-restriction
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3869 (save-window-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3870 (set-buffer (cperl-info-buffer nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3871 (setq imenu-create-index-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3872 'imenu-default-create-index-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3873 imenu-prev-index-position-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3874 'cperl-imenu-info-imenu-search
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3875 imenu-extract-index-name-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3876 'cperl-imenu-info-imenu-name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3877 (imenu-choose-buffer-index)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3878 (and index-item
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3879 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3880 (push-mark)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3881 (pop-to-buffer "*info-perl*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3882 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3883 ((markerp (cdr index-item))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3884 (goto-char (marker-position (cdr index-item))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3885 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3886 (goto-char (cdr index-item))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3887 (set-window-start (selected-window) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3888 (pop-to-buffer buffer)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3889
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3890 (defun cperl-lineup (beg end &optional step minshift)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3891 "Lineup construction in a region.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3892 Beginning of region should be at the start of a construction.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3893 All first occurrences of this construction in the lines that are
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3894 partially contained in the region are lined up at the same column.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3895
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3896 MINSHIFT is the minimal amount of space to insert before the construction.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3897 STEP is the tabwidth to position constructions.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3898 If STEP is `nil', `cperl-lineup-step' will be used
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3899 \(or `cperl-indent-level', if `cperl-lineup-step' is `nil').
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3900 Will not move the position at the start to the left."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3901 (interactive "r")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3902 (let (search col tcol seen b e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3903 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3904 (goto-char end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3905 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3906 (setq end (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3907 (goto-char beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3908 (skip-chars-forward " \t\f")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3909 (setq beg (point-marker))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3910 (indent-region beg end nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3911 (goto-char beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3912 (setq col (current-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3913 (if (looking-at "[a-zA-Z0-9_]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3914 (if (looking-at "\\<[a-zA-Z0-9_]+\\>")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3915 (setq search
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3916 (concat "\\<"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3917 (regexp-quote
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3918 (buffer-substring (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3919 (match-end 0))) "\\>"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3920 (error "Cannot line up in a middle of the word"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3921 (if (looking-at "$")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3922 (error "Cannot line up end of line"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3923 (setq search (regexp-quote (char-to-string (following-char)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3924 (setq step (or step cperl-lineup-step cperl-indent-level))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3925 (or minshift (setq minshift 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3926 (while (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3927 (beginning-of-line 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3928 (and (< (point) end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3929 (re-search-forward search end t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3930 (goto-char (match-beginning 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3931 (setq tcol (current-column) seen t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3932 (if (> tcol col) (setq col tcol)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3933 (or seen
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3934 (error "The construction to line up occurred only once"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3935 (goto-char beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3936 (setq col (+ col minshift))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3937 (if (/= (% col step) 0) (setq step (* step (1+ (/ col step)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3938 (while
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3939 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3940 (setq e (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3941 (skip-chars-backward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3942 (delete-region (point) e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3943 (indent-to-column col); (make-string (- col (current-column)) ?\ ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3944 (beginning-of-line 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3945 (and (< (point) end)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3946 (re-search-forward search end t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3947 (goto-char (match-beginning 0)))))))) ; No body
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3948
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3949 (defun cperl-etags (&optional add all files)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3950 "Run etags with appropriate options for Perl files.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3951 If optional argument ALL is `recursive', will process Perl files
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3952 in subdirectories too."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3953 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3954 (let ((cmd "etags")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3955 (args '("-l" "none" "-r" "/\\<\\(package\\|sub\\)[ \\t]+\\(\\([a-zA-Z0-9:_]*::\\)?\\([a-zA-Z0-9_]+\\)[ \\t]*\\(([^()]*)[ \t]*\\)?\\([{#]\\|$\\)\\)/\\4/"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3956 res)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3957 (if add (setq args (cons "-a" args)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3958 (or files (setq files (list buffer-file-name)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3959 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3960 ((eq all 'recursive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3961 ;;(error "Not implemented: recursive")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3962 (setq args (append (list "-e"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3963 "sub wanted {push @ARGV, $File::Find::name if /\\.[pP][Llm]$/}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3964 use File::Find;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3965 find(\\&wanted, '.');
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3966 exec @ARGV;"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3967 cmd) args)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3968 cmd "perl"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3969 (all
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3970 ;;(error "Not implemented: all")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3971 (setq args (append (list "-e"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3972 "push @ARGV, <*.PL *.pl *.pm>;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3973 exec @ARGV;"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3974 cmd) args)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3975 cmd "perl"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3976 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3977 (setq args (append args files))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3978 (setq res (apply 'call-process cmd nil nil nil args))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3979 (or (eq res 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3980 (message "etags returned \"%s\"" res))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3981
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3982 (defun cperl-toggle-auto-newline ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3983 "Toggle the state of `cperl-auto-newline'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3984 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3985 (setq cperl-auto-newline (not cperl-auto-newline))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3986 (message "Newlines will %sbe auto-inserted now."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3987 (if cperl-auto-newline "" "not ")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3988
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3989 (defun cperl-toggle-abbrev ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3990 "Toggle the state of automatic keyword expansion in CPerl mode."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3991 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3992 (abbrev-mode (if abbrev-mode 0 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3993 (message "Perl control structure will %sbe auto-inserted now."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3994 (if abbrev-mode "" "not ")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3995
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3996
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3997 (defun cperl-toggle-electric ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3998 "Toggle the state of parentheses doubling in CPerl mode."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3999 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4000 (setq cperl-electric-parens (if (cperl-val 'cperl-electric-parens) 'null t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4001 (message "Parentheses will %sbe auto-doubled now."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4002 (if (cperl-val 'cperl-electric-parens) "" "not ")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4003
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4004 ;;;; Tags file creation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4005
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4006 (defvar cperl-tmp-buffer " *cperl-tmp*")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4007
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4008 (defun cperl-setup-tmp-buf ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4009 (set-buffer (get-buffer-create cperl-tmp-buffer))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4010 (set-syntax-table cperl-mode-syntax-table)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4011 (buffer-disable-undo)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4012 (auto-fill-mode 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4013 (if cperl-use-syntax-table-text-property-for-tags
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4014 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4015 (make-variable-buffer-local 'parse-sexp-lookup-properties)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4016 ;; Do not introduce variable if not needed, we check it!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4017 (set 'parse-sexp-lookup-properties t))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4018
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4019 (defun cperl-xsub-scan ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4020 (require 'cl)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4021 (require 'imenu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4022 (let ((index-alist '())
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4023 (prev-pos 0) index index1 name package prefix)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4024 (goto-char (point-min))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4025 (if noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4026 (message "Scanning XSUB for index")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4027 (imenu-progress-message prev-pos 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4028 ;; Search for the function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4029 (progn ;;save-match-data
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4030 (while (re-search-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4031 "^\\([ \t]*MODULE\\>[^\n]*\\<PACKAGE[ \t]*=[ \t]*\\([a-zA-Z_][a-zA-Z_0-9:]*\\)\\>\\|\\([a-zA-Z_][a-zA-Z_0-9]*\\)(\\|[ \t]*BOOT:\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4032 nil t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4033 (or noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4034 (imenu-progress-message prev-pos))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4035 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4036 ((match-beginning 2) ; SECTION
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4037 (setq package (buffer-substring (match-beginning 2) (match-end 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4038 (goto-char (match-beginning 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4039 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4040 (forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4041 (if (looking-at "[^\n]*\\<PREFIX[ \t]*=[ \t]*\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\>")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4042 (setq prefix (buffer-substring (match-beginning 1) (match-end 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4043 (setq prefix nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4044 ((not package) nil) ; C language section
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4045 ((match-beginning 3) ; XSUB
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4046 (goto-char (1+ (match-beginning 3)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4047 (setq index (imenu-example--name-and-position))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4048 (setq name (buffer-substring (match-beginning 3) (match-end 3)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4049 (if (and prefix (string-match (concat "^" prefix) name))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4050 (setq name (substring name (length prefix))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4051 (cond ((string-match "::" name) nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4052 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4053 (setq index1 (cons (concat package "::" name) (cdr index)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4054 (push index1 index-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4055 (setcar index name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4056 (push index index-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4057 (t ; BOOT: section
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4058 ;; (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4059 (setq index (imenu-example--name-and-position))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4060 (setcar index (concat package "::BOOT:"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4061 (push index index-alist)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4062 (or noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4063 (imenu-progress-message prev-pos 100))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4064 ;;(setq index-alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4065 ;; (if (default-value 'imenu-sort-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4066 ;; (sort index-alist (default-value 'imenu-sort-function))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4067 ;; (nreverse index-alist)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4068 index-alist))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4069
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4070 (defun cperl-find-tags (file xs topdir)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4071 (let (ind (b (get-buffer cperl-tmp-buffer)) lst elt pos ret rel
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4072 (cperl-pod-here-fontify nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4073 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4074 (if b (set-buffer b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4075 (cperl-setup-tmp-buf))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4076 (erase-buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4077 (setq file (car (insert-file-contents file)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4078 (message "Scanning file %s ..." file)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4079 (if (and cperl-use-syntax-table-text-property-for-tags
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4080 (not xs))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4081 (condition-case err ; after __END__ may have garbage
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4082 (cperl-find-pods-heres)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4083 (error (message "While scanning for syntax: %s" err))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4084 (if xs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4085 (setq lst (cperl-xsub-scan))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4086 (setq ind (imenu-example--create-perl-index))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4087 (setq lst (cdr (assoc "+Unsorted List+..." ind))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4088 (setq lst
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4089 (mapcar
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4090 (function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4091 (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4092 (cond ((string-match "^[_a-zA-Z]" (car elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4093 (goto-char (cdr elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4094 (list (car elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4095 (point) (count-lines 1 (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4096 (buffer-substring (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4097 (skip-chars-forward
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4098 ":_a-zA-Z0-9")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4099 (or (eolp) (forward-char 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4100 (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4101 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4102 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4103 (point))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4104 lst))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4105 (erase-buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4106 (while lst
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4107 (setq elt (car lst) lst (cdr lst))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4108 (if elt
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4109 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4110 (insert (elt elt 3)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4111 127
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4112 (if (string-match "^package " (car elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4113 (substring (car elt) 8)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4114 (car elt) )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4115 1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4116 (number-to-string (elt elt 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4117 ","
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4118 (number-to-string (elt elt 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4119 "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4120 (if (and (string-match "^[_a-zA-Z]+::" (car elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4121 (string-match "^sub[ \t]+\\([_a-zA-Z]+\\)[^:_a-zA-Z]"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4122 (elt elt 3)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4123 ;; Need to insert the name without package as well
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4124 (setq lst (cons (cons (substring (elt elt 3)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4125 (match-beginning 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4126 (match-end 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4127 (cdr elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4128 lst))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4129 (setq pos (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4130 (goto-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4131 (setq rel file)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4132 ;; On case-preserving filesystems (EMX on OS/2) case might be encoded in properties
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4133 (set-text-properties 0 (length rel) nil rel)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4134 (and (equal topdir (substring rel 0 (length topdir)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4135 (setq rel (substring file (length topdir))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4136 (insert "\f\n" rel "," (number-to-string (1- pos)) "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4137 (setq ret (buffer-substring 1 (point-max)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4138 (erase-buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4139 (or noninteractive
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4140 (message "Scanning file %s finished" file))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4141 ret)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4142
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4143 (defun cperl-add-tags-recurse-noxs ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4144 "Add to TAGS data for Perl and XSUB files in the current directory and kids.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4145 Use as
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4146 emacs -batch -q -no-site-file -l emacs/cperl-mode.el \
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4147 -f cperl-add-tags-recurse
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4148 "
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4149 (cperl-write-tags nil nil t t nil t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4150
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4151 (defun cperl-add-tags-recurse ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4152 "Add to TAGS file data for Perl files in the current directory and kids.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4153 Use as
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4154 emacs -batch -q -no-site-file -l emacs/cperl-mode.el \
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4155 -f cperl-add-tags-recurse
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4156 "
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4157 (cperl-write-tags nil nil t t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4158
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4159 (defun cperl-write-tags (&optional file erase recurse dir inbuffer noxs topdir)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4160 ;; If INBUFFER, do not select buffer, and do not save
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4161 ;; If ERASE is `ignore', do not erase, and do not try to delete old info.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4162 (require 'etags)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4163 (if file nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4164 (setq file (if dir default-directory (buffer-file-name)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4165 (if (and (not dir) (buffer-modified-p)) (error "Save buffer first!")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4166 (or topdir
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4167 (setq topdir default-directory))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4168 (let ((tags-file-name "TAGS")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4169 (case-fold-search (eq system-type 'emx))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4170 xs)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4171 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4172 (cond (inbuffer nil) ; Already there
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4173 ((file-exists-p tags-file-name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4174 (visit-tags-table-buffer tags-file-name))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4175 (t (set-buffer (find-file-noselect tags-file-name))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4176 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4177 (dir
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4178 (cond ((eq erase 'ignore))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4179 (erase
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4180 (erase-buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4181 (setq erase 'ignore)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4182 (let ((files
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4183 (directory-files file t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4184 (if recurse nil cperl-scan-files-regexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4185 t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4186 (mapcar (function (lambda (file)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4187 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4188 ((string-match cperl-noscan-files-regexp file)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4189 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4190 ((not (file-directory-p file))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4191 (if (string-match cperl-scan-files-regexp file)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4192 (cperl-write-tags file erase recurse nil t noxs topdir)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4193 ((not recurse) nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4194 (t (cperl-write-tags file erase recurse t t noxs topdir)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4195 files))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4196 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4197 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4198 (setq xs (string-match "\\.xs$" file))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4199 (if (not (and xs noxs))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4200 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4201 (cond ((eq erase 'ignore) (goto-char (point-max)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4202 (erase (erase-buffer))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4203 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4204 (goto-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4205 (if (search-forward (concat "\f\n" file ",") nil t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4206 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4207 (search-backward "\f\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4208 (delete-region (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4209 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4210 (forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4211 (if (search-forward "\f\n"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4212 nil 'toend)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4213 (- (point) 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4214 (point-max)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4215 (goto-char (point-max)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4216 (insert (cperl-find-tags file xs topdir))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4217 (if inbuffer nil ; Delegate to the caller
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4218 (save-buffer 0) ; No backup
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4219 (if (fboundp 'initialize-new-tags-table) ; Do we need something special in XEmacs?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4220 (initialize-new-tags-table))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4221
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4222 (defvar cperl-tags-hier-regexp-list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4223 (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4224 "^\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4225 "\\(package\\)\\>"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4226 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4227 "sub\\>[^\n]+::"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4228 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4229 "[a-zA-Z_][a-zA-Z_0-9:]*(\C-?[^\n]+::" ; XSUB?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4230 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4231 "[ \t]*BOOT:\C-?[^\n]+::" ; BOOT section
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4232 "\\)"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4233
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4234 (defvar cperl-hierarchy '(() ())
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4235 "Global hierarchy of classes")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4236
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4237 (defun cperl-tags-hier-fill ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4238 ;; Suppose we are in a tag table cooked by cperl.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4239 (goto-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4240 (let (type pack name pos line chunk ord cons1 file str info fileind)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4241 (while (re-search-forward cperl-tags-hier-regexp-list nil t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4242 (setq pos (match-beginning 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4243 pack (match-beginning 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4244 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4245 (if (looking-at (concat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4246 "\\([^\n]+\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4247 "\C-?"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4248 "\\([^\n]+\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4249 "\C-a"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4250 "\\([0-9]+\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4251 ","
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4252 "\\([0-9]+\\)"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4253 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4254 (setq ;;str (buffer-substring (match-beginning 1) (match-end 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4255 name (buffer-substring (match-beginning 2) (match-end 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4256 ;;pos (buffer-substring (match-beginning 3) (match-end 3))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4257 line (buffer-substring (match-beginning 4) (match-end 4))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4258 ord (if pack 1 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4259 info (etags-snarf-tag) ; Moves to beginning of the next line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4260 file (file-of-tag)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4261 fileind (format "%s:%s" file line))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4262 ;; Move back
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4263 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4264 ;; Make new member of hierarchy name ==> file ==> pos if needed
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4265 (if (setq cons1 (assoc name (nth ord cperl-hierarchy)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4266 ;; Name known
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4267 (setcdr cons1 (cons (cons fileind (vector file info))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4268 (cdr cons1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4269 ;; First occurrence of the name, start alist
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4270 (setq cons1 (cons name (list (cons fileind (vector file info)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4271 (if pack
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4272 (setcar (cdr cperl-hierarchy)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4273 (cons cons1 (nth 1 cperl-hierarchy)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4274 (setcar cperl-hierarchy
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4275 (cons cons1 (car cperl-hierarchy)))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4276 (end-of-line))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4277
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4278 (defun cperl-tags-hier-init (&optional update)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4279 "Show hierarchical menu of classes and methods.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4280 Finds info about classes by a scan of loaded TAGS files.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4281 Supposes that the TAGS files contain fully qualified function names.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4282 One may build such TAGS files from CPerl mode menu."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4283 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4284 (require 'etags)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4285 (require 'imenu)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4286 (if (or update (null (nth 2 cperl-hierarchy)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4287 (let (pack name cons1 to l1 l2 l3 l4
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4288 (remover (function (lambda (elt) ; (name (file1...) (file2..))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4289 (or (nthcdr 2 elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4290 ;; Only in one file
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4291 (setcdr elt (cdr (nth 1 elt))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4292 ;; (setq cperl-hierarchy '(() () ())) ; Would write into '() later!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4293 (setq cperl-hierarchy (list l1 l2 l3))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4294 (or tags-table-list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4295 (call-interactively 'visit-tags-table))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4296 (message "Updating list of classes...")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4297 (mapcar
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4298 (function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4299 (lambda (tagsfile)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4300 (set-buffer (get-file-buffer tagsfile))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4301 (cperl-tags-hier-fill)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4302 tags-table-list)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4303 (mapcar remover (car cperl-hierarchy))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4304 (mapcar remover (nth 1 cperl-hierarchy))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4305 (setq to (list nil (cons "Packages: " (nth 1 cperl-hierarchy))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4306 (cons "Methods: " (car cperl-hierarchy))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4307 (cperl-tags-treeify to 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4308 (setcar (nthcdr 2 cperl-hierarchy)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4309 (cperl-menu-to-keymap (cons '("+++UPDATE+++" . -999) (cdr to))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4310 (message "Updating list of classes: done, requesting display...")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4311 ;;(cperl-imenu-addback (nth 2 cperl-hierarchy))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4312 ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4313 (or (nth 2 cperl-hierarchy)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4314 (error "No items found"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4315 (setq update
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4316 ;;; (imenu-choose-buffer-index "Packages: " (nth 2 cperl-hierarchy))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4317 (if window-system
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4318 (x-popup-menu t (nth 2 cperl-hierarchy))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4319 (require 'tmm)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4320 (tmm-prompt (nth 2 cperl-hierarchy))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4321 (if (and update (listp update))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4322 (progn (while (cdr update) (setq update (cdr update)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4323 (setq update (car update)))) ; Get the last from the list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4324 (if (vectorp update)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4325 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4326 (find-file (elt update 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4327 (etags-goto-tag-location (elt update 1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4328 (if (eq update -999) (cperl-tags-hier-init t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4329
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4330 (defun cperl-tags-treeify (to level)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4331 ;; cadr of `to' is read-write. On start it is a cons
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4332 (let* ((regexp (concat "^\\(" (mapconcat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4333 'identity
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4334 (make-list level "[_a-zA-Z0-9]+")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4335 "::")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4336 "\\)\\(::\\)?"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4337 (packages (cdr (nth 1 to)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4338 (methods (cdr (nth 2 to)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4339 l1 head tail cons1 cons2 ord writeto packs recurse
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4340 root-packages root-functions ms many_ms same_name ps
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4341 (move-deeper
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4342 (function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4343 (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4344 (cond ((and (string-match regexp (car elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4345 (or (eq ord 1) (match-end 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4346 (setq head (substring (car elt) 0 (match-end 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4347 tail (if (match-end 2) (substring (car elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4348 (match-end 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4349 recurse t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4350 (if (setq cons1 (assoc head writeto)) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4351 ;; Need to init new head
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4352 (setcdr writeto (cons (list head (list "Packages: ")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4353 (list "Methods: "))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4354 (cdr writeto)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4355 (setq cons1 (nth 1 writeto)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4356 (setq cons2 (nth ord cons1)) ; Either packs or meths
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4357 (setcdr cons2 (cons elt (cdr cons2))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4358 ((eq ord 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4359 (setq root-functions (cons elt root-functions)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4360 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4361 (setq root-packages (cons elt root-packages))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4362 (setcdr to l1) ; Init to dynamic space
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4363 (setq writeto to)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4364 (setq ord 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4365 (mapcar move-deeper packages)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4366 (setq ord 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4367 (mapcar move-deeper methods)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4368 (if recurse
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4369 (mapcar (function (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4370 (cperl-tags-treeify elt (1+ level))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4371 (cdr to)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4372 ;;Now clean up leaders with one child only
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4373 (mapcar (function (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4374 (if (not (and (listp (cdr elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4375 (eq (length elt) 2))) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4376 (setcar elt (car (nth 1 elt)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4377 (setcdr elt (cdr (nth 1 elt))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4378 (cdr to))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4379 ;; Sort the roots of subtrees
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4380 (if (default-value 'imenu-sort-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4381 (setcdr to
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4382 (sort (cdr to) (default-value 'imenu-sort-function))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4383 ;; Now add back functions removed from display
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4384 (mapcar (function (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4385 (setcdr to (cons elt (cdr to)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4386 (if (default-value 'imenu-sort-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4387 (nreverse
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4388 (sort root-functions (default-value 'imenu-sort-function)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4389 root-functions))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4390 ;; Now add back packages removed from display
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4391 (mapcar (function (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4392 (setcdr to (cons (cons (concat "package " (car elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4393 (cdr elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4394 (cdr to)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4395 (if (default-value 'imenu-sort-function)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4396 (nreverse
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4397 (sort root-packages (default-value 'imenu-sort-function)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4398 root-packages))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4399 ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4400
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4401 ;;;(x-popup-menu t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4402 ;;; '(keymap "Name1"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4403 ;;; ("Ret1" "aa")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4404 ;;; ("Head1" "ab"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4405 ;;; keymap "Name2"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4406 ;;; ("Tail1" "x") ("Tail2" "y"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4407
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4408 (defun cperl-list-fold (list name limit)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4409 (let (list1 list2 elt1 (num 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4410 (if (<= (length list) limit) list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4411 (setq list1 nil list2 nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4412 (while list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4413 (setq num (1+ num)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4414 elt1 (car list)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4415 list (cdr list))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4416 (if (<= num imenu-max-items)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4417 (setq list2 (cons elt1 list2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4418 (setq list1 (cons (cons name
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4419 (nreverse list2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4420 list1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4421 list2 (list elt1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4422 num 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4423 (nreverse (cons (cons name
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4424 (nreverse list2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4425 list1)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4426
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4427 (defun cperl-menu-to-keymap (menu &optional name)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4428 (let (list)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4429 (cons 'keymap
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4430 (mapcar
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4431 (function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4432 (lambda (elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4433 (cond ((listp (cdr elt))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4434 (setq list (cperl-list-fold
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4435 (cdr elt) (car elt) imenu-max-items))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4436 (cons nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4437 (cons (car elt)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4438 (cperl-menu-to-keymap list))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4439 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4440 (list (cdr elt) (car elt) t))))) ; t is needed in 19.34
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4441 (cperl-list-fold menu "Root" imenu-max-items)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4442
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4443
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4444 (defvar cperl-bad-style-regexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4445 (mapconcat 'identity
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4446 '("[^-\n\t <>=+!.&|(*/'`\"#^][-=+<>!|&^]" ; char sign
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4447 "[-<>=+^&|]+[^- \t\n=+<>~]" ; sign+ char
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4448 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4449 "\\|")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4450 "Finds places such that insertion of a whitespace may help a lot.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4451
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4452 (defvar cperl-not-bad-style-regexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4453 (mapconcat 'identity
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4454 '("[^-\t <>=+]\\(--\\|\\+\\+\\)" ; var-- var++
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4455 "[a-zA-Z0-9_][|&][a-zA-Z0-9_$]" ; abc|def abc&def are often used.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4456 "&[(a-zA-Z0-9_$]" ; &subroutine &(var->field)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4457 "<\\$?\\sw+\\(\\.\\sw+\\)?>" ; <IN> <stdin.h>
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4458 "-[a-zA-Z][ \t]+[_$\"'`]" ; -f file
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4459 "-[0-9]" ; -5
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4460 "\\+\\+" ; ++var
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4461 "--" ; --var
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4462 ".->" ; a->b
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4463 "->" ; a SPACE ->b
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4464 "\\[-" ; a[-1]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4465 "^=" ; =head
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4466 "||"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4467 "&&"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4468 "[CBIXSLFZ]<\\(\\sw\\|\\s \\|\\s_\\|[\n]\\)*>" ; C<code like text>
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4469 "-[a-zA-Z_0-9]+[ \t]*=>" ; -option => value
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4470 ;; Unaddressed trouble spots: = -abc, f(56, -abc) --- specialcased below
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4471 ;;"[*/+-|&<.]+="
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4472 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4473 "\\|")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4474 "If matches at the start of match found by `my-bad-c-style-regexp',
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4475 insertion of a whitespace will not help.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4476
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4477 (defvar found-bad)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4478
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4479 (defun cperl-find-bad-style ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4480 "Find places in the buffer where insertion of a whitespace may help.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4481 Prompts user for insertion of spaces.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4482 Currently it is tuned to C and Perl syntax."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4483 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4484 (let (found-bad (p (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4485 (setq last-nonmenu-event 13) ; To disable popup
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4486 (beginning-of-buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4487 (map-y-or-n-p "Insert space here? "
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4488 (function (lambda (arg) (insert " ")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4489 'cperl-next-bad-style
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4490 '("location" "locations" "insert a space into")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4491 '((?\C-r (lambda (arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4492 (let ((buffer-quit-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4493 'exit-recursive-edit))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4494 (message "Exit with Esc Esc")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4495 (recursive-edit)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4496 t)) ; Consider acted upon
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4497 "edit, exit with Esc Esc")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4498 (?e (lambda (arg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4499 (let ((buffer-quit-function
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4500 'exit-recursive-edit))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4501 (message "Exit with Esc Esc")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4502 (recursive-edit)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4503 t)) ; Consider acted upon
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4504 "edit, exit with Esc Esc"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4505 t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4506 (if found-bad (goto-char found-bad)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4507 (goto-char p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4508 (message "No appropriate place found"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4509
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4510 (defun cperl-next-bad-style ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4511 (let (p (not-found t) (point (point)) found)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4512 (while (and not-found
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4513 (re-search-forward cperl-bad-style-regexp nil 'to-end))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4514 (setq p (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4515 (goto-char (match-beginning 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4516 (if (or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4517 (looking-at cperl-not-bad-style-regexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4518 ;; Check for a < -b and friends
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4519 (and (eq (following-char) ?\-)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4520 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4521 (skip-chars-backward " \t\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4522 (memq (preceding-char) '(?\= ?\> ?\< ?\, ?\(, ?\[, ?\{))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4523 ;; Now check for syntax type
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4524 (save-match-data
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4525 (setq found (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4526 (beginning-of-defun)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4527 (let ((pps (parse-partial-sexp (point) found)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4528 (or (nth 3 pps) (nth 4 pps) (nth 5 pps)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4529 (goto-char (match-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4530 (goto-char (1- p))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4531 (setq not-found nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4532 found-bad found)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4533 (not not-found)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4534
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4535 ;;; Getting help
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4536 (defvar cperl-have-help-regexp
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4537 ;;(concat "\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4538 (mapconcat
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4539 'identity
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4540 '("[$@%*&][0-9a-zA-Z_:]+\\([ \t]*[[{]\\)?" ; Usual variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4541 "[$@]\\^[a-zA-Z]" ; Special variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4542 "[$@][^ \n\t]" ; Special variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4543 "-[a-zA-Z]" ; File test
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4544 "\\\\[a-zA-Z0]" ; Special chars
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4545 "^=[a-z][a-zA-Z0-9_]*" ; Pod sections
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4546 "[-!&*+,-./<=>?\\\\^|~]+" ; Operator
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4547 "[a-zA-Z_0-9:]+" ; symbol or number
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4548 "x="
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4549 "#!"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4550 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4551 ;;"\\)\\|\\("
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4552 "\\|"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4553 )
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4554 ;;"\\)"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4555 ;;)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4556 "Matches places in the buffer we can find help for.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4557
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4558 (defvar cperl-message-on-help-error t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4559 (defvar cperl-help-from-timer nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4560
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4561 (defun cperl-word-at-point-hard ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4562 ;; Does not save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4563 ;; Get to the something meaningful
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4564 (or (eobp) (eolp) (forward-char 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4565 (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4566 (save-excursion (beginning-of-line) (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4567 'to-beg)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4568 ;; (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4569 ;; ((or (eobp) (looking-at "[][ \t\n{}();,]")) ; Not at a symbol
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4570 ;; (skip-chars-backward " \n\t\r({[]});,")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4571 ;; (or (bobp) (backward-char 1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4572 ;; Try to backtrace
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4573 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4574 ((looking-at "[a-zA-Z0-9_:]") ; symbol
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4575 (skip-chars-backward "a-zA-Z0-9_:")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4576 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4577 ((and (eq (preceding-char) ?^) ; $^I
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4578 (eq (char-after (- (point) 2)) ?\$))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4579 (forward-char -2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4580 ((memq (preceding-char) (append "*$@%&\\" nil)) ; *glob
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4581 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4582 ((and (eq (preceding-char) ?\=)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4583 (eq (current-column) 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4584 (forward-char -1))) ; =head1
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4585 (if (and (eq (preceding-char) ?\<)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4586 (looking-at "\\$?[a-zA-Z0-9_:]+>")) ; <FH>
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4587 (forward-char -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4588 ((and (looking-at "=") (eq (preceding-char) ?x)) ; x=
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4589 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4590 ((and (looking-at "\\^") (eq (preceding-char) ?\$)) ; $^I
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4591 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4592 ((looking-at "[-!&*+,-./<=>?\\\\^|~]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4593 (skip-chars-backward "-!&*+,-./<=>?\\\\^|~")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4594 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4595 ((and (eq (preceding-char) ?\$)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4596 (not (eq (char-after (- (point) 2)) ?\$))) ; $-
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4597 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4598 ((and (eq (following-char) ?\>)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4599 (string-match "[a-zA-Z0-9_]" (char-to-string (preceding-char)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4600 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4601 (forward-sexp -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4602 (and (eq (preceding-char) ?\<)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4603 (looking-at "\\$?[a-zA-Z0-9_:]+>")))) ; <FH>
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4604 (search-backward "<"))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4605 ((and (eq (following-char) ?\$)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4606 (eq (preceding-char) ?\<)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4607 (looking-at "\\$?[a-zA-Z0-9_:]+>")) ; <$fh>
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4608 (forward-char -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4609 (if (looking-at cperl-have-help-regexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4610 (buffer-substring (match-beginning 0) (match-end 0))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4611
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4612 (defun cperl-get-help ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4613 "Get one-line docs on the symbol at the point.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4614 The data for these docs is a little bit obsolete and may be in fact longer
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4615 than a line. Your contribution to update/shorten it is appreciated."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4616 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4617 (save-match-data ; May be called "inside" query-replace
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4618 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4619 (let ((word (cperl-word-at-point-hard)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4620 (if word
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4621 (if (and cperl-help-from-timer ; Bail out if not in mainland
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4622 (not (string-match "^#!\\|\\\\\\|^=" word)) ; Show help even in comments/strings.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4623 (or (memq (get-text-property (point) 'face)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4624 '(font-lock-comment-face font-lock-string-face))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4625 (memq (get-text-property (point) 'syntax-type)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4626 '(pod here-doc format))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4627 nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4628 (cperl-describe-perl-symbol word))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4629 (if cperl-message-on-help-error
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4630 (message "Nothing found for %s..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4631 (buffer-substring (point) (min (+ 5 (point)) (point-max))))))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4632
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4633 ;;; Stolen from perl-descr.el by Johan Vromans:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4634
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4635 (defvar cperl-doc-buffer " *perl-doc*"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4636 "Where the documentation can be found.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4637
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4638 (defun cperl-describe-perl-symbol (val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4639 "Display the documentation of symbol at point, a Perl operator."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4640 (let ((enable-recursive-minibuffers t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4641 args-file regexp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4642 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4643 ((string-match "^[&*][a-zA-Z_]" val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4644 (setq val (concat (substring val 0 1) "NAME")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4645 ((string-match "^[$@]\\([a-zA-Z_:0-9]+\\)[ \t]*\\[" val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4646 (setq val (concat "@" (substring val 1 (match-end 1)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4647 ((string-match "^[$@]\\([a-zA-Z_:0-9]+\\)[ \t]*{" val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4648 (setq val (concat "%" (substring val 1 (match-end 1)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4649 ((and (string= val "x") (string-match "^x=" val))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4650 (setq val "x="))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4651 ((string-match "^\\$[\C-a-\C-z]" val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4652 (setq val (concat "$^" (char-to-string (+ ?A -1 (aref val 1))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4653 ((string-match "^CORE::" val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4654 (setq val "CORE::"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4655 ((string-match "^SUPER::" val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4656 (setq val "SUPER::"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4657 ((and (string= "<" val) (string-match "^<\\$?[a-zA-Z0-9_:]+>" val))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4658 (setq val "<NAME>")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4659 (setq regexp (concat "^"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4660 "\\([^a-zA-Z0-9_:]+[ \t]+\\)?"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4661 (regexp-quote val)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4662 "\\([ \t([/]\\|$\\)"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4663
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4664 ;; get the buffer with the documentation text
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4665 (cperl-switch-to-doc-buffer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4666
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4667 ;; lookup in the doc
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4668 (goto-char (point-min))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4669 (let ((case-fold-search nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4670 (list
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4671 (if (re-search-forward regexp (point-max) t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4672 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4673 (beginning-of-line 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4674 (let ((lnstart (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4675 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4676 (message "%s" (buffer-substring lnstart (point)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4677 (if cperl-message-on-help-error
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4678 (message "No definition for %s" val)))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4679
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4680 (defvar cperl-short-docs "Ignore my value"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4681 ;; Perl4 version was written by Johan Vromans (jvromans@squirrel.nl)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4682 "# based on '@(#)@ perl-descr.el 1.9 - describe-perl-symbol' [Perl 5]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4683 ! ... Logical negation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4684 ... != ... Numeric inequality.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4685 ... !~ ... Search pattern, substitution, or translation (negated).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4686 $! In numeric context: errno. In a string context: error string.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4687 $\" The separator which joins elements of arrays interpolated in strings.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4688 $# The output format for printed numbers. Initial value is %.15g or close.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4689 $$ Process number of this script. Changes in the fork()ed child process.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4690 $% The current page number of the currently selected output channel.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4691
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4692 The following variables are always local to the current block:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4693
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4694 $1 Match of the 1st set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4695 $2 Match of the 2nd set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4696 $3 Match of the 3rd set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4697 $4 Match of the 4th set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4698 $5 Match of the 5th set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4699 $6 Match of the 6th set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4700 $7 Match of the 7th set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4701 $8 Match of the 8th set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4702 $9 Match of the 9th set of parentheses in the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4703 $& The string matched by the last pattern match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4704 $' The string after what was matched by the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4705 $` The string before what was matched by the last match (auto-local).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4706
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4707 $( The real gid of this process.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4708 $) The effective gid of this process.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4709 $* Deprecated: Set to 1 to do multiline matching within a string.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4710 $+ The last bracket matched by the last search pattern.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4711 $, The output field separator for the print operator.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4712 $- The number of lines left on the page.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4713 $. The current input line number of the last filehandle that was read.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4714 $/ The input record separator, newline by default.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4715 $0 Name of the file containing the perl script being executed. May be set.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4716 $: String may be broken after these characters to fill ^-lines in a format.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4717 $; Subscript separator for multi-dim array emulation. Default \"\\034\".
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4718 $< The real uid of this process.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4719 $= The page length of the current output channel. Default is 60 lines.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4720 $> The effective uid of this process.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4721 $? The status returned by the last ``, pipe close or `system'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4722 $@ The perl error message from the last eval or do @var{EXPR} command.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4723 $ARGV The name of the current file used with <> .
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4724 $[ Deprecated: The index of the first element/char in an array/string.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4725 $\\ The output record separator for the print operator.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4726 $] The perl version string as displayed with perl -v.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4727 $^ The name of the current top-of-page format.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4728 $^A The current value of the write() accumulator for format() lines.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4729 $^D The value of the perl debug (-D) flags.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4730 $^E Information about the last system error other than that provided by $!.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4731 $^F The highest system file descriptor, ordinarily 2.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4732 $^H The current set of syntax checks enabled by `use strict'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4733 $^I The value of the in-place edit extension (perl -i option).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4734 $^L What formats output to perform a formfeed. Default is \f.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4735 $^O The operating system name under which this copy of Perl was built.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4736 $^P Internal debugging flag.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4737 $^T The time the script was started. Used by -A/-M/-C file tests.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4738 $^W True if warnings are requested (perl -w flag).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4739 $^X The name under which perl was invoked (argv[0] in C-speech).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4740 $_ The default input and pattern-searching space.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4741 $| Auto-flush after write/print on current output channel? Default 0.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4742 $~ The name of the current report format.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4743 ... % ... Modulo division.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4744 ... %= ... Modulo division assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4745 %ENV Contains the current environment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4746 %INC List of files that have been require-d or do-ne.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4747 %SIG Used to set signal handlers for various signals.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4748 ... & ... Bitwise and.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4749 ... && ... Logical and.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4750 ... &&= ... Logical and assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4751 ... &= ... Bitwise and assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4752 ... * ... Multiplication.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4753 ... ** ... Exponentiation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4754 *NAME Glob: all objects refered by NAME. *NAM1 = *NAM2 aliases NAM1 to NAM2.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4755 &NAME(arg0, ...) Subroutine call. Arguments go to @_.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4756 ... + ... Addition. +EXPR Makes EXPR into scalar context.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4757 ++ Auto-increment (magical on strings). ++EXPR EXPR++
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4758 ... += ... Addition assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4759 , Comma operator.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4760 ... - ... Subtraction.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4761 -- Auto-decrement (NOT magical on strings). --EXPR EXPR--
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4762 ... -= ... Subtraction assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4763 -A Access time in days since script started.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4764 -B File is a non-text (binary) file.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4765 -C Inode change time in days since script started.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4766 -M Age in days since script started.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4767 -O File is owned by real uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4768 -R File is readable by real uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4769 -S File is a socket .
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4770 -T File is a text file.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4771 -W File is writable by real uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4772 -X File is executable by real uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4773 -b File is a block special file.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4774 -c File is a character special file.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4775 -d File is a directory.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4776 -e File exists .
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4777 -f File is a plain file.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4778 -g File has setgid bit set.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4779 -k File has sticky bit set.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4780 -l File is a symbolic link.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4781 -o File is owned by effective uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4782 -p File is a named pipe (FIFO).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4783 -r File is readable by effective uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4784 -s File has non-zero size.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4785 -t Tests if filehandle (STDIN by default) is opened to a tty.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4786 -u File has setuid bit set.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4787 -w File is writable by effective uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4788 -x File is executable by effective uid.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4789 -z File has zero size.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4790 . Concatenate strings.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4791 .. Alternation, also range operator.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4792 .= Concatenate assignment strings
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4793 ... / ... Division. /PATTERN/ioxsmg Pattern match
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4794 ... /= ... Division assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4795 /PATTERN/ioxsmg Pattern match.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4796 ... < ... Numeric less than. <pattern> Glob. See <NAME>, <> as well.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4797 <NAME> Reads line from filehandle NAME (a bareword or dollar-bareword).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4798 <pattern> Glob (Unless pattern is bareword/dollar-bareword - see <NAME>).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4799 <> Reads line from union of files in @ARGV (= command line) and STDIN.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4800 ... << ... Bitwise shift left. << start of HERE-DOCUMENT.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4801 ... <= ... Numeric less than or equal to.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4802 ... <=> ... Numeric compare.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4803 ... = ... Assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4804 ... == ... Numeric equality.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4805 ... =~ ... Search pattern, substitution, or translation
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4806 ... > ... Numeric greater than.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4807 ... >= ... Numeric greater than or equal to.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4808 ... >> ... Bitwise shift right.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4809 ... >>= ... Bitwise shift right assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4810 ... ? ... : ... Condition=if-then-else operator. ?PAT? One-time pattern match.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4811 ?PATTERN? One-time pattern match.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4812 @ARGV Command line arguments (not including the command name - see $0).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4813 @INC List of places to look for perl scripts during do/include/use.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4814 @_ Parameter array for subroutines. Also used by split unless in array context.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4815 \\ Creates reference to what follows, like \$var, or quotes non-\w in strings.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4816 \\0 Octal char, e.g. \\033.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4817 \\E Case modification terminator. See \\Q, \\L, and \\U.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4818 \\L Lowercase until \\E . See also \l, lc.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4819 \\U Upcase until \\E . See also \u, uc.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4820 \\Q Quote metacharacters until \\E . See also quotemeta.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4821 \\a Alarm character (octal 007).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4822 \\b Backspace character (octal 010).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4823 \\c Control character, e.g. \\c[ .
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4824 \\e Escape character (octal 033).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4825 \\f Formfeed character (octal 014).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4826 \\l Lowercase the next character. See also \\L and \\u, lcfirst.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4827 \\n Newline character (octal 012 on most systems).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4828 \\r Return character (octal 015 on most systems).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4829 \\t Tab character (octal 011).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4830 \\u Upcase the next character. See also \\U and \\l, ucfirst.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4831 \\x Hex character, e.g. \\x1b.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4832 ... ^ ... Bitwise exclusive or.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4833 __END__ Ends program source.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4834 __DATA__ Ends program source.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4835 __FILE__ Current (source) filename.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4836 __LINE__ Current line in current source.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4837 __PACKAGE__ Current package.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4838 ARGV Default multi-file input filehandle. <ARGV> is a synonym for <>.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4839 ARGVOUT Output filehandle with -i flag.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4840 BEGIN { ... } Immediately executed (during compilation) piece of code.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4841 END { ... } Pseudo-subroutine executed after the script finishes.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4842 DATA Input filehandle for what follows after __END__ or __DATA__.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4843 accept(NEWSOCKET,GENERICSOCKET)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4844 alarm(SECONDS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4845 atan2(X,Y)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4846 bind(SOCKET,NAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4847 binmode(FILEHANDLE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4848 caller[(LEVEL)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4849 chdir(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4850 chmod(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4851 chop[(LIST|VAR)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4852 chown(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4853 chroot(FILENAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4854 close(FILEHANDLE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4855 closedir(DIRHANDLE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4856 ... cmp ... String compare.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4857 connect(SOCKET,NAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4858 continue of { block } continue { block }. Is executed after `next' or at end.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4859 cos(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4860 crypt(PLAINTEXT,SALT)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4861 dbmclose(%HASH)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4862 dbmopen(%HASH,DBNAME,MODE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4863 defined(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4864 delete($HASH{KEY})
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4865 die(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4866 do { ... }|SUBR while|until EXPR executes at least once
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4867 do(EXPR|SUBR([LIST])) (with while|until executes at least once)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4868 dump LABEL
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4869 each(%HASH)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4870 endgrent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4871 endhostent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4872 endnetent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4873 endprotoent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4874 endpwent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4875 endservent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4876 eof[([FILEHANDLE])]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4877 ... eq ... String equality.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4878 eval(EXPR) or eval { BLOCK }
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4879 exec(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4880 exit(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4881 exp(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4882 fcntl(FILEHANDLE,FUNCTION,SCALAR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4883 fileno(FILEHANDLE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4884 flock(FILEHANDLE,OPERATION)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4885 for (EXPR;EXPR;EXPR) { ... }
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4886 foreach [VAR] (@ARRAY) { ... }
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4887 fork
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4888 ... ge ... String greater than or equal.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4889 getc[(FILEHANDLE)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4890 getgrent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4891 getgrgid(GID)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4892 getgrnam(NAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4893 gethostbyaddr(ADDR,ADDRTYPE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4894 gethostbyname(NAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4895 gethostent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4896 getlogin
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4897 getnetbyaddr(ADDR,ADDRTYPE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4898 getnetbyname(NAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4899 getnetent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4900 getpeername(SOCKET)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4901 getpgrp(PID)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4902 getppid
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4903 getpriority(WHICH,WHO)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4904 getprotobyname(NAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4905 getprotobynumber(NUMBER)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4906 getprotoent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4907 getpwent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4908 getpwnam(NAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4909 getpwuid(UID)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4910 getservbyname(NAME,PROTO)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4911 getservbyport(PORT,PROTO)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4912 getservent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4913 getsockname(SOCKET)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4914 getsockopt(SOCKET,LEVEL,OPTNAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4915 gmtime(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4916 goto LABEL
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4917 grep(EXPR,LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4918 ... gt ... String greater than.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4919 hex(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4920 if (EXPR) { ... } [ elsif (EXPR) { ... } ... ] [ else { ... } ] or EXPR if EXPR
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4921 index(STR,SUBSTR[,OFFSET])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4922 int(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4923 ioctl(FILEHANDLE,FUNCTION,SCALAR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4924 join(EXPR,LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4925 keys(%HASH)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4926 kill(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4927 last [LABEL]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4928 ... le ... String less than or equal.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4929 length(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4930 link(OLDFILE,NEWFILE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4931 listen(SOCKET,QUEUESIZE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4932 local(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4933 localtime(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4934 log(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4935 lstat(EXPR|FILEHANDLE|VAR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4936 ... lt ... String less than.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4937 m/PATTERN/iogsmx
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4938 mkdir(FILENAME,MODE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4939 msgctl(ID,CMD,ARG)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4940 msgget(KEY,FLAGS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4941 msgrcv(ID,VAR,SIZE,TYPE.FLAGS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4942 msgsnd(ID,MSG,FLAGS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4943 my VAR or my (VAR1,...) Introduces a lexical variable ($VAR, @ARR, or %HASH).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4944 ... ne ... String inequality.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4945 next [LABEL]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4946 oct(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4947 open(FILEHANDLE[,EXPR])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4948 opendir(DIRHANDLE,EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4949 ord(EXPR) ASCII value of the first char of the string.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4950 pack(TEMPLATE,LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4951 package NAME Introduces package context.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4952 pipe(READHANDLE,WRITEHANDLE) Create a pair of filehandles on ends of a pipe.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4953 pop(ARRAY)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4954 print [FILEHANDLE] [(LIST)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4955 printf [FILEHANDLE] (FORMAT,LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4956 push(ARRAY,LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4957 q/STRING/ Synonym for 'STRING'
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4958 qq/STRING/ Synonym for \"STRING\"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4959 qx/STRING/ Synonym for `STRING`
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4960 rand[(EXPR)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4961 read(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4962 readdir(DIRHANDLE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4963 readlink(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4964 recv(SOCKET,SCALAR,LEN,FLAGS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4965 redo [LABEL]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4966 rename(OLDNAME,NEWNAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4967 require [FILENAME | PERL_VERSION]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4968 reset[(EXPR)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4969 return(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4970 reverse(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4971 rewinddir(DIRHANDLE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4972 rindex(STR,SUBSTR[,OFFSET])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4973 rmdir(FILENAME)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4974 s/PATTERN/REPLACEMENT/gieoxsm
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4975 scalar(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4976 seek(FILEHANDLE,POSITION,WHENCE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4977 seekdir(DIRHANDLE,POS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4978 select(FILEHANDLE | RBITS,WBITS,EBITS,TIMEOUT)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4979 semctl(ID,SEMNUM,CMD,ARG)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4980 semget(KEY,NSEMS,SIZE,FLAGS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4981 semop(KEY,...)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4982 send(SOCKET,MSG,FLAGS[,TO])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4983 setgrent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4984 sethostent(STAYOPEN)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4985 setnetent(STAYOPEN)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4986 setpgrp(PID,PGRP)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4987 setpriority(WHICH,WHO,PRIORITY)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4988 setprotoent(STAYOPEN)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4989 setpwent
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4990 setservent(STAYOPEN)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4991 setsockopt(SOCKET,LEVEL,OPTNAME,OPTVAL)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4992 shift[(ARRAY)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4993 shmctl(ID,CMD,ARG)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4994 shmget(KEY,SIZE,FLAGS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4995 shmread(ID,VAR,POS,SIZE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4996 shmwrite(ID,STRING,POS,SIZE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4997 shutdown(SOCKET,HOW)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4998 sin(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4999 sleep[(EXPR)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5000 socket(SOCKET,DOMAIN,TYPE,PROTOCOL)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5001 socketpair(SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5002 sort [SUBROUTINE] (LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5003 splice(ARRAY,OFFSET[,LENGTH[,LIST]])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5004 split[(/PATTERN/[,EXPR[,LIMIT]])]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5005 sprintf(FORMAT,LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5006 sqrt(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5007 srand(EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5008 stat(EXPR|FILEHANDLE|VAR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5009 study[(SCALAR)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5010 sub [NAME [(format)]] { BODY } sub NAME [(format)]; sub [(format)] {...}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5011 substr(EXPR,OFFSET[,LEN])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5012 symlink(OLDFILE,NEWFILE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5013 syscall(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5014 sysread(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5015 system(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5016 syswrite(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5017 tell[(FILEHANDLE)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5018 telldir(DIRHANDLE)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5019 time
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5020 times
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5021 tr/SEARCHLIST/REPLACEMENTLIST/cds
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5022 truncate(FILE|EXPR,LENGTH)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5023 umask[(EXPR)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5024 undef[(EXPR)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5025 unless (EXPR) { ... } [ else { ... } ] or EXPR unless EXPR
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5026 unlink(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5027 unpack(TEMPLATE,EXPR)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5028 unshift(ARRAY,LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5029 until (EXPR) { ... } EXPR until EXPR
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5030 utime(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5031 values(%HASH)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5032 vec(EXPR,OFFSET,BITS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5033 wait
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5034 waitpid(PID,FLAGS)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5035 wantarray Returns true if the sub/eval is called in list context.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5036 warn(LIST)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5037 while (EXPR) { ... } EXPR while EXPR
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5038 write[(EXPR|FILEHANDLE)]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5039 ... x ... Repeat string or array.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5040 x= ... Repetition assignment.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5041 y/SEARCHLIST/REPLACEMENTLIST/
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5042 ... | ... Bitwise or.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5043 ... || ... Logical or.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5044 ~ ... Unary bitwise complement.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5045 #! OS interpreter indicator. If has `perl', used for options, and -x.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5046 AUTOLOAD {...} Shorthand for `sub AUTOLOAD {...}'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5047 CORE:: Prefix to access builtin function if imported sub obscures it.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5048 SUPER:: Prefix to lookup for a method in @ISA classes.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5049 DESTROY Shorthand for `sub DESTROY {...}'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5050 ... EQ ... Obsolete synonym of `eq'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5051 ... GE ... Obsolete synonym of `ge'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5052 ... GT ... Obsolete synonym of `gt'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5053 ... LE ... Obsolete synonym of `le'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5054 ... LT ... Obsolete synonym of `lt'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5055 ... NE ... Obsolete synonym of `ne'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5056 abs [ EXPR ] absolute value
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5057 ... and ... Low-precedence synonym for &&.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5058 bless REFERENCE [, PACKAGE] Makes reference into an object of a package.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5059 chomp [LIST] Strips $/ off LIST/$_. Returns count. Special if $/ eq ''!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5060 chr Converts a number to char with the same ordinal.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5061 else Part of if/unless {BLOCK} elsif {BLOCK} else {BLOCK}.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5062 elsif Part of if/unless {BLOCK} elsif {BLOCK} else {BLOCK}.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5063 exists $HASH{KEY} True if the key exists.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5064 format [NAME] = Start of output format. Ended by a single dot (.) on a line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5065 formline PICTURE, LIST Backdoor into \"format\" processing.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5066 glob EXPR Synonym of <EXPR>.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5067 lc [ EXPR ] Returns lowercased EXPR.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5068 lcfirst [ EXPR ] Returns EXPR with lower-cased first letter.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5069 map EXPR, LIST or map {BLOCK} LIST Applies EXPR/BLOCK to elts of LIST.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5070 no PACKAGE [SYMBOL1, ...] Partial reverse for `use'. Runs `unimport' method.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5071 not ... Low-precedence synonym for ! - negation.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5072 ... or ... Low-precedence synonym for ||.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5073 pos STRING Set/Get end-position of the last match over this string, see \\G.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5074 quotemeta [ EXPR ] Quote regexp metacharacters.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5075 qw/WORD1 .../ Synonym of split('', 'WORD1 ...')
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5076 readline FH Synonym of <FH>.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5077 readpipe CMD Synonym of `CMD`.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5078 ref [ EXPR ] Type of EXPR when dereferenced.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5079 sysopen FH, FILENAME, MODE [, PERM] (MODE is numeric, see Fcntl.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5080 tie VAR, PACKAGE, LIST Hide an object behind a simple Perl variable.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5081 tied Returns internal object for a tied data.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5082 uc [ EXPR ] Returns upcased EXPR.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5083 ucfirst [ EXPR ] Returns EXPR with upcased first letter.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5084 untie VAR Unlink an object from a simple Perl variable.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5085 use PACKAGE [SYMBOL1, ...] Compile-time `require' with consequent `import'.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5086 ... xor ... Low-precedence synonym for exclusive or.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5087 prototype \&SUB Returns prototype of the function given a reference.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5088 =head1 Top-level heading.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5089 =head2 Second-level heading.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5090 =head3 Third-level heading (is there such?).
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5091 =over [ NUMBER ] Start list.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5092 =item [ TITLE ] Start new item in the list.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5093 =back End list.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5094 =cut Switch from POD to Perl.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5095 =pod Switch from Perl to POD.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5096 ")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5097
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5098 (defun cperl-switch-to-doc-buffer ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5099 "Go to the perl documentation buffer and insert the documentation."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5100 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5101 (let ((buf (get-buffer-create cperl-doc-buffer)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5102 (if (interactive-p)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5103 (switch-to-buffer-other-window buf)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5104 (set-buffer buf))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5105 (if (= (buffer-size) 0)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5106 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5107 (insert (documentation-property 'cperl-short-docs
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5108 'variable-documentation))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5109 (setq buffer-read-only t)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5110
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5111 (defun cperl-beautify-regexp-piece (b e embed)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5112 ;; b is before the starting delimiter, e before the ending
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5113 ;; e should be a marker, may be changed, but remains "correct".
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5114 (let (s c tmp (m (make-marker)) (m1 (make-marker)) c1 spaces inline code)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5115 (if (not embed)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5116 (goto-char (1+ b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5117 (goto-char b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5118 (cond ((looking-at "(\\?\\\\#") ; badly commented (?#)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5119 (forward-char 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5120 (delete-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5121 (forward-char 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5122 ((looking-at "(\\?[^a-zA-Z]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5123 (forward-char 3))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5124 ((looking-at "(\\?") ; (?i)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5125 (forward-char 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5126 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5127 (forward-char 1))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5128 (setq c (if embed (current-indentation) (1- (current-column)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5129 c1 (+ c (or cperl-regexp-indent-step cperl-indent-level)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5130 (or (looking-at "[ \t]*[\n#]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5131 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5132 (insert "\n")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5133 (goto-char e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5134 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5135 (if (re-search-forward "[^ \t]" e t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5136 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5137 (goto-char e)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5138 (insert "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5139 (indent-to-column c)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5140 (set-marker e (point))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5141 (goto-char b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5142 (end-of-line 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5143 (while (< (point) (marker-position e))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5144 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5145 (setq s (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5146 inline t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5147 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5148 (delete-region s (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5149 (indent-to-column c1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5150 (while (and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5151 inline
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5152 (looking-at
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5153 (concat "\\([a-zA-Z0-9]+[^*+{?]\\)" ; 1 word
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5154 "\\|" ; Embedded variable
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5155 "\\$\\([a-zA-Z0-9_]+\\([[{]\\)?\\|[^\n \t)|]\\)" ; 2 3
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5156 "\\|" ; $ ^
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5157 "[$^]"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5158 "\\|" ; simple-code simple-code*?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5159 "\\(\\\\.\\|[^][()#|*+?\n]\\)\\([*+{?]\\??\\)?" ; 4 5
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5160 "\\|" ; Class
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5161 "\\(\\[\\)" ; 6
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5162 "\\|" ; Grouping
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5163 "\\((\\(\\?\\)?\\)" ; 7 8
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5164 "\\|" ; |
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5165 "\\(|\\)" ; 9
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5166 )))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5167 (goto-char (match-end 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5168 (setq spaces t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5169 (cond ((match-beginning 1) ; Alphanum word + junk
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5170 (forward-char -1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5171 ((or (match-beginning 3) ; $ab[12]
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5172 (and (match-beginning 5) ; X* X+ X{2,3}
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5173 (eq (preceding-char) ?\{)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5174 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5175 (forward-sexp 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5176 ((match-beginning 6) ; []
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5177 (setq tmp (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5178 (if (looking-at "\\^?\\]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5179 (goto-char (match-end 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5180 (or (re-search-forward "\\]\\([*+{?]\\)?" e t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5181 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5182 (goto-char (1- tmp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5183 (error "[]-group not terminated")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5184 (if (not (eq (preceding-char) ?\{)) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5185 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5186 (forward-sexp 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5187 ((match-beginning 7) ; ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5188 (goto-char (match-beginning 0))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5189 (or (eq (current-column) c1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5190 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5191 (insert "\n")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5192 (indent-to-column c1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5193 (setq tmp (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5194 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5195 ;; (or (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5196 ;; (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5197 ;; (goto-char tmp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5198 ;; (error "()-group not terminated")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5199 (set-marker m (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5200 (set-marker m1 (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5201 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5202 ((not (match-beginning 8))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5203 (cperl-beautify-regexp-piece tmp m t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5204 ((eq (char-after (+ 2 tmp)) ?\{) ; Code
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5205 t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5206 ((eq (char-after (+ 2 tmp)) ?\() ; Conditional
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5207 (goto-char (+ 2 tmp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5208 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5209 (cperl-beautify-regexp-piece (point) m t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5210 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5211 (cperl-beautify-regexp-piece tmp m t)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5212 (goto-char m1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5213 (cond ((looking-at "[*+?]\\??")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5214 (goto-char (match-end 0)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5215 ((eq (following-char) ?\{)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5216 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5217 (if (eq (following-char) ?\?)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5218 (forward-char))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5219 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5220 (setq spaces nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5221 (if (looking-at "[#\n]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5222 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5223 (or (eolp) (indent-for-comment))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5224 (beginning-of-line 2))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5225 (insert "\n"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5226 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5227 (setq inline nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5228 ((match-beginning 9) ; |
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5229 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5230 (setq tmp (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5231 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5232 (if (re-search-forward "[^ \t]" tmp t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5233 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5234 (goto-char tmp)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5235 (insert "\n"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5236 ;; first at line
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5237 (delete-region (point) tmp))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5238 (indent-to-column c)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5239 (forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5240 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5241 (setq spaces nil)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5242 (if (looking-at "[#\n]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5243 (beginning-of-line 2)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5244 (insert "\n"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5245 (end-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5246 (setq inline nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5247 (or (looking-at "[ \t\n]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5248 (not spaces)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5249 (insert " "))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5250 (skip-chars-forward " \t"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5251 (or (looking-at "[#\n]")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5252 (error "unknown code \"%s\" in a regexp" (buffer-substring (point)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5253 (1+ (point)))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5254 (and inline (end-of-line 2)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5255 ;; Special-case the last line of group
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5256 (if (and (>= (point) (marker-position e))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5257 (/= (current-indentation) c))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5258 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5259 (beginning-of-line)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5260 (setq s (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5261 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5262 (delete-region s (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5263 (indent-to-column c)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5264 ))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5265
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5266 (defun cperl-make-regexp-x ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5267 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5268 (or cperl-use-syntax-table-text-property
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5269 (error "I need to have regex marked!"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5270 ;; Find the start
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5271 (re-search-backward "\\s|") ; Assume it is scanned already.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5272 ;;(forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5273 (let ((b (point)) (e (make-marker)) have-x delim (c (current-column))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5274 (sub-p (eq (preceding-char) ?s)) s)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5275 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5276 (set-marker e (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5277 (setq delim (preceding-char))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5278 (if (and sub-p (eq delim (char-after (- (point) 2))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5279 (error "Possible s/blah// - do not know how to deal with"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5280 (if sub-p (forward-sexp 1))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5281 (if (looking-at "\\sw*x")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5282 (setq have-x t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5283 (insert "x"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5284 ;; Protect fragile " ", "#"
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5285 (if have-x nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5286 (goto-char (1+ b))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5287 (while (re-search-forward "\\(\\=\\|[^\\\\]\\)\\(\\\\\\\\\\)*[ \t\n#]" e t) ; Need to include (?#) too?
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5288 (forward-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5289 (insert "\\")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5290 (forward-char 1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5291 b)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5292
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5293 (defun cperl-beautify-regexp ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5294 "do it. (Experimental, may change semantics, recheck the result.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5295 We suppose that the regexp is scanned already."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5296 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5297 (cperl-make-regexp-x)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5298 (re-search-backward "\\s|") ; Assume it is scanned already.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5299 ;;(forward-char 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5300 (let ((b (point)) (e (make-marker)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5301 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5302 (set-marker e (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5303 (cperl-beautify-regexp-piece b e nil)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5304
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5305 (defun cperl-contract-level ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5306 "Find an enclosing group in regexp and contract it. Unfinished.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5307 \(Experimental, may change semantics, recheck the result.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5308 We suppose that the regexp is scanned already."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5309 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5310 (let ((bb (cperl-make-regexp-x)) done)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5311 (while (not done)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5312 (or (eq (following-char) ?\()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5313 (search-backward "(" (1+ bb) t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5314 (error "Cannot find `(' which starts a group"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5315 (setq done
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5316 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5317 (skip-chars-backward "\\")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5318 (looking-at "\\(\\\\\\\\\\)*(")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5319 (or done (forward-char -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5320 (let ((b (point)) (e (make-marker)) s c)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5321 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5322 (set-marker e (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5323 (goto-char b)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5324 (while (re-search-forward "\\(#\\)\\|\n" e t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5325 (cond
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5326 ((match-beginning 1) ; #-comment
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5327 (or c (setq c (current-indentation)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5328 (beginning-of-line 2) ; Skip
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5329 (setq s (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5330 (skip-chars-forward " \t")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5331 (delete-region s (point))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5332 (indent-to-column c))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5333 (t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5334 (delete-char -1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5335 (just-one-space)))))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5336
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5337 (defun cperl-beautify-level ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5338 "Find an enclosing group in regexp and beautify it.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5339 \(Experimental, may change semantics, recheck the result.)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5340 We suppose that the regexp is scanned already."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5341 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5342 (let ((bb (cperl-make-regexp-x)) done)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5343 (while (not done)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5344 (or (eq (following-char) ?\()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5345 (search-backward "(" (1+ bb) t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5346 (error "Cannot find `(' which starts a group"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5347 (setq done
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5348 (save-excursion
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5349 (skip-chars-backward "\\")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5350 (looking-at "\\(\\\\\\\\\\)*(")))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5351 (or done (forward-char -1)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5352 (let ((b (point)) (e (make-marker)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5353 (forward-sexp 1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5354 (set-marker e (1- (point)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5355 (cperl-beautify-regexp-piece b e nil))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5356
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5357 (if (fboundp 'run-with-idle-timer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5358 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5359 (defvar cperl-help-shown nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5360 "Non-nil means that the help was already shown now.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5361
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5362 (defvar cperl-lazy-installed nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5363 "Non-nil means that the lazy-help handlers are installed now.")
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5364
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5365 (defun cperl-lazy-install ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5366 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5367 (make-variable-buffer-local 'cperl-help-shown)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5368 (if (and (cperl-val 'cperl-lazy-help-time)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5369 (not cperl-lazy-installed))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5370 (progn
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5371 (add-hook 'post-command-hook 'cperl-lazy-hook)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5372 (run-with-idle-timer
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5373 (cperl-val 'cperl-lazy-help-time 1000000 5)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5374 t
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5375 'cperl-get-help-defer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5376 (setq cperl-lazy-installed t))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5377
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5378 (defun cperl-lazy-unstall ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5379 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5380 (remove-hook 'post-command-hook 'cperl-lazy-hook)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5381 (cancel-function-timers 'cperl-get-help-defer)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5382 (setq cperl-lazy-installed nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5383
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5384 (defun cperl-lazy-hook ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5385 (setq cperl-help-shown nil))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5386
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5387 (defun cperl-get-help-defer ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5388 (if (not (eq major-mode 'perl-mode)) nil
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5389 (let ((cperl-message-on-help-error nil) (cperl-help-from-timer t))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5390 (cperl-get-help)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5391 (setq cperl-help-shown t))))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5392 (cperl-lazy-install)))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5393
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5394 (provide 'cperl-mode)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5395
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5396 ;;; cperl-mode.el ends here