Commit db133cb6 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(cperl-style-alist): New variable, since `c-mode'

is no longer loaded.
- (Somebody who uses the styles should check that they work OK!)
- (a lot of work is needed, especially with new
  `cperl-fix-line-spacing').
Old value of style is memorized when choosing a new style, may be
restored from the same menu.
(cperl-perldoc, cperl-pod-to-manpage): New commands; thanks to
Anthony Foiani <afoiani@uswest.com> and Nick Roberts
<Nick.Roberts@src.bae.co.uk>.
(`Perl doc', `Regexp'): New submenus (latter to allow short displays).
(cperl-clobber-lisp-bindings): New cfg variable.
(cperl-find-pods-heres): $a->y() is not y///.
(cperl-after-block-p): Add save-excursion.
(cperl-init-faces): Was failing.
Init faces when loading `ps-print'.
(cperl-toggle-autohelp): New command.
(cperl-electric-paren): `while SPACE LESS' was buggy.
(cperl-init-faces): `-text' in `[-text => 1]' was not highlighted.
(cperl-after-block-p): was FALSE after `sub f {}'.
(cperl-electric-keyword): `foreachmy', `formy' expanded too,
Expands `=pod-directive'.
(cperl-linefeed): behaves reasonable in POD-directive lines.
(cperl-message-electric-keyword): new cfg variable.
(cperl-electric-keyword): print a message, governed by
`cperl-message-electric-keyword'.
(cperl-electric-paren): Typing `}' was not checking for being
block or not.
(cperl-beautify-regexp-piece): Did not know about lookbehind;
finding *which* level to work with was not intuitive.
(cperl-beautify-levels): New command.
(cperl-electric-keyword): Allow here-docs contain `=head1'
and friends for keyword expansion.
Fix for broken `font-lock-unfontify-region-function'.  Should
preserve `syntax-table' properties even with `lazy-lock'.
(cperl-indent-region-fix-else): New command.
(cperl-fix-line-spacing): New command.
(cperl-invert-if-unless): New command (C-c C-t and in Menu).
(cperl-hints): mention 20.2's goods/bads.
(cperl-extra-newline-before-brace-multiline): Started to use it.
(cperl-break-one-line-blocks-when-indent): New cfg variable.
(cperl-fix-hanging-brace-when-indent): New cfg variable.
(cperl-merge-trailing-else): New cfg variable.
Workaround for another `font-lock's `syntax-table' text-property bug.
`zerop' could be applied to nil.
At last, may work with `font-lock' without setting `cperl-font-lock'.
(cperl-indent-region-fix-constructs): Renamed from
`cperl-indent-region-fix-constructs'.
(cperl-fix-line-spacing): could be triggered inside strings, would not
know what to do with BLOCKs of map/printf/etc.
(cperl-merge-trailing-else): Handle `continue' too.
(cperl-fix-line-spacing): Likewise.
(cperl-calculate-indent): Knows about map/printf/etc before {BLOCK};
treat after-comma lines as continuation lines.
(cperl-mode): `continue' made electric.
(cperl-electric-keyword): Electric `do' inserts `do/while'.
(cperl-fontify-syntaxically): New function.
(cperl-syntaxify-by-font-lock): New cfg variable.
Make syntaxification to be autoredone via `font-lock',
switched on by `cperl-syntaxify-by-font-lock', off by default so far.
Remove some commented out chunks.
(cperl-set-style-back): Old value of style is memorized when
choosing a new style, may be restored from the same menu.
Mode-documentation added to micro-docs.
(cperl-praise): updated.
(cperl-toggle-construct-fix): New command.  Added on C-c C-w and menu.
(auto-fill-mode): added on C-c C-f and menu.
(cperl-style-alist): `PerlStyle' style added.
(cperl-find-pods-heres): Message for termination of scan corrected.
(cperl-speed): New variable with hints.
(cperl-electric-else): Make backspace electric after
expansion of `else/continue' too.
Fixed customization to honor cperl-hairy.
Created customization groups.
All the compile-time warnings fixed.
(cperl-syntaxify-by-font-lock): Interaction with `font-lock-hot-pass'
fixed.
(cperl-after-block-and-statement-beg): It is BLOCK if we reach lim
when backup sexp.
(cperl-after-block-p, cperl-after-expr-p): Likewise.
(cperl-indent-region): Make a marker for END - text added/removed.
(cperl-style-alist): Include `cperl-merge-trailing-else'
where the value is clear.
(cperl-styles-entries): Likewise.
(cperl-tips, cperl-problems): Improvements to docs.
parent 68dabb61
......@@ -39,7 +39,7 @@
;;; DO NOT FORGET to read micro-docs (available from `Perl' menu) <<<<<<
;;; or as help on variables `cperl-tips', `cperl-problems', <<<<<<
;;; `cperl-non-problems', `cperl-praise'. <<<<<<
;;; `cperl-non-problems', `cperl-praise', `cperl-speed'. <<<<<<
;;; The mode information (on C-h m) provides some customization help.
;;; If you use font-lock feature of this mode, it is advisable to use
......@@ -66,9 +66,39 @@
(defgroup cperl nil
"Major mode for editing Perl code."
:prefix "cperl-"
:group 'languages)
:group 'languages
:version "20.3")
(defgroup cperl-indentation-details nil
"Indentation."
:prefix "cperl-"
:group 'cperl)
(defgroup cperl-affected-by-hairy nil
"Variables affected by `cperl-hairy'."
:prefix "cperl-"
:group 'cperl)
(defgroup cperl-autoinsert-details nil
"Auto-insert tuneup."
:prefix "cperl-"
:group 'cperl)
(defgroup cperl-faces nil
"Fontification colors."
:prefix "cperl-"
:group 'cperl)
(defgroup cperl-speed nil
"Speed vs. validity tuneup."
:prefix "cperl-"
:group 'cperl)
(defgroup cperl-help-system nil
"Help system tuneup."
:prefix "cperl-"
:group 'cperl)
(defconst cperl-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version))
(defcustom cperl-extra-newline-before-brace nil
"*Non-nil means that if, elsif, while, until, else, for, foreach
......@@ -84,50 +114,58 @@ instead of:
}
"
:type 'boolean
:group 'cperl)
:group 'cperl-autoinsert-details)
(defcustom cperl-extra-newline-before-brace-multiline
cperl-extra-newline-before-brace
"*Non-nil means the same as `cperl-extra-newline-before-brace', but
for constructs with multiline if/unless/while/until/for/foreach condition."
:type 'boolean
:group 'cperl-autoinsert-details)
(defcustom cperl-indent-level 2
"*Indentation of CPerl statements with respect to containing block."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-lineup-step nil
"*`cperl-lineup' will always lineup at multiple of this number.
If `nil', the value of `cperl-indent-level' will be used."
:type '(choice (const nil) integer)
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-brace-imaginary-offset 0
"*Imagined indentation of a Perl open brace that actually follows a statement.
An open brace following other text is treated as if it were this far
to the right of the start of its line."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-brace-offset 0
"*Extra indentation for braces, compared with other text in same context."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-label-offset -2
"*Offset of CPerl label lines relative to usual indentation."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-min-label-indent 1
"*Minimal offset of CPerl label lines."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-continued-statement-offset 2
"*Extra indent for lines not starting new statements."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-continued-brace-offset 0
"*Extra indent for substatements that start with open-braces.
This is in addition to cperl-continued-statement-offset."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-close-paren-offset -1
"*Extra indent for substatements that start with close-parenthesis."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-auto-newline nil
"*Non-nil means automatically newline before and after braces,
......@@ -136,43 +174,46 @@ and after colons and semicolons, inserted in CPerl code. The following
Insertion after colons requires both this variable and
`cperl-auto-newline-after-colon' set."
:type 'boolean
:group 'cperl)
:group 'cperl-autoinsert-details)
(defcustom cperl-auto-newline-after-colon nil
"*Non-nil means automatically newline even after colons.
Subject to `cperl-auto-newline' setting."
:type 'boolean
:group 'cperl)
:group 'cperl-autoinsert-details)
(defcustom cperl-tab-always-indent t
"*Non-nil means TAB in CPerl mode should always reindent the current line,
regardless of where in the line point is when the TAB command is used."
:type 'boolean
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-font-lock nil
"*Non-nil (and non-null) means CPerl buffers will use font-lock-mode.
Can be overwritten by `cperl-hairy' if nil."
:type 'boolean
:group 'cperl)
:type '(choice (const null) boolean)
:group 'cperl-affected-by-hairy)
(defcustom cperl-electric-lbrace-space nil
"*Non-nil (and non-null) means { after $ in CPerl buffers should be preceded by ` '.
Can be overwritten by `cperl-hairy' if nil."
:type 'boolean
:group 'cperl)
:type '(choice (const null) boolean)
:group 'cperl-affected-by-hairy)
(defcustom cperl-electric-parens-string "({[]})<"
"*String of parentheses that should be electric in CPerl.
Closing ones are electric only if the region is highlighted."
:type 'string
:group 'cperl)
:group 'cperl-affected-by-hairy)
(defcustom cperl-electric-parens nil
"*Non-nil (and non-null) means parentheses should be electric in CPerl.
Can be overwritten by `cperl-hairy' if nil."
:type 'boolean
:group 'cperl)
:type '(choice (const null) boolean)
:group 'cperl-affected-by-hairy)
(defvar zmacs-regions) ; Avoid warning
(defcustom cperl-electric-parens-mark
(and window-system
(or (and (boundp 'transient-mark-mode) ; For Emacs
......@@ -182,30 +223,34 @@ Can be overwritten by `cperl-hairy' if nil."
"*Not-nil means that electric parens look for active mark.
Default is yes if there is visual feedback on mark."
:type 'boolean
:group 'cperl)
:group 'cperl-autoinsert-details)
(defcustom cperl-electric-linefeed nil
"*If true, LFD should be hairy in CPerl, otherwise C-c LFD is hairy.
In any case these two mean plain and hairy linefeeds together.
Can be overwritten by `cperl-hairy' if nil."
:type 'boolean
:group 'cperl)
:type '(choice (const null) boolean)
:group 'cperl-affected-by-hairy)
(defcustom cperl-electric-keywords nil
"*Not-nil (and non-null) means keywords are electric in CPerl.
Can be overwritten by `cperl-hairy' if nil."
:type 'boolean
:group 'cperl)
:type '(choice (const null) boolean)
:group 'cperl-affected-by-hairy)
(defcustom cperl-hairy nil
"*Not-nil means all the bells and whistles are enabled in CPerl."
"*Not-nil means most of the bells and whistles are enabled in CPerl.
Affects: `cperl-font-lock', `cperl-electric-lbrace-space',
`cperl-electric-parens', `cperl-electric-linefeed', `cperl-electric-keywords',
`cperl-info-on-command-no-prompt', `cperl-clobber-lisp-bindings',
`cperl-lazy-help-time'."
:type 'boolean
:group 'cperl)
:group 'cperl-affected-by-hairy)
(defcustom cperl-comment-column 32
"*Column to put comments in CPerl (use \\[cperl-indent] to lineup with code)."
:type 'integer
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-vc-header-alist '((SCCS "$sccs = '%W\%' ;")
(RCS "$rcs = ' $Id\$ ' ;"))
......@@ -217,74 +262,82 @@ Can be overwritten by `cperl-hairy' if nil."
"*Not-nil (and non-null) means not to prompt on C-h f.
The opposite behaviour is always available if prefixed with C-c.
Can be overwritten by `cperl-hairy' if nil."
:type 'boolean
:group 'cperl)
:type '(choice (const null) boolean)
:group 'cperl-affected-by-hairy)
(defcustom cperl-clobber-lisp-bindings nil
"*Not-nil (and non-null) means not overwrite C-h f.
The function is available on \\[cperl-info-on-command], \\[cperl-get-help].
Can be overwritten by `cperl-hairy' if nil."
:type '(choice (const null) boolean)
:group 'cperl-affected-by-hairy)
(defcustom cperl-lazy-help-time nil
"*Not-nil (and non-null) means to show lazy help after given idle time."
:type 'boolean
:group 'cperl)
"*Not-nil (and non-null) means to show lazy help after given idle time.
Can be overwritten by `cperl-hairy' to be 5 sec if nil."
:type '(choice (const null) integer)
:group 'cperl-affected-by-hairy)
(defcustom cperl-pod-face 'font-lock-comment-face
"*The result of evaluation of this expression is used for pod highlighting."
:type 'face
:group 'cperl)
:group 'cperl-faces)
(defcustom cperl-pod-head-face 'font-lock-variable-name-face
"*The result of evaluation of this expression is used for pod highlighting.
Font for POD headers."
:type 'face
:group 'cperl)
:group 'cperl-faces)
(defcustom cperl-here-face 'font-lock-string-face
"*The result of evaluation of this expression is used for here-docs highlighting."
:type 'face
:group 'cperl)
:group 'cperl-faces)
(defcustom cperl-pod-here-fontify '(featurep 'font-lock)
"*Not-nil after evaluation means to highlight pod and here-docs sections."
:type 'boolean
:group 'cperl)
:group 'cperl-faces)
(defcustom cperl-pod-here-scan t
"*Not-nil means look for pod and here-docs sections during startup.
You can always make lookup from menu or using \\[cperl-find-pods-heres]."
:type 'boolean
:group 'cperl)
:group 'cperl-speed)
(defcustom cperl-imenu-addback nil
"*Not-nil means add backreferences to generated `imenu's.
May require patched `imenu' and `imenu-go'."
May require patched `imenu' and `imenu-go'. Obsolete."
:type 'boolean
:group 'cperl)
:group 'cperl-help-system)
(defcustom cperl-max-help-size 66
"*Non-nil means shrink-wrapping of info-buffer allowed up to these percents."
:type '(choice integer (const nil))
:group 'cperl)
:group 'cperl-help-system)
(defcustom cperl-shrink-wrap-info-frame t
"*Non-nil means shrink-wrapping of info-buffer-frame allowed."
:type 'boolean
:group 'cperl)
:group 'cperl-help-system)
(defcustom cperl-info-page "perl"
"*Name of the info page containing perl docs.
Older version of this page was called `perl5', newer `perl'."
:type 'string
:group 'cperl)
:group 'cperl-help-system)
(defcustom cperl-use-syntax-table-text-property
(boundp 'parse-sexp-lookup-properties)
"*Non-nil means CPerl sets up and uses `syntax-table' text property."
:type 'boolean
:group 'cperl)
:group 'cperl-speed)
(defcustom cperl-use-syntax-table-text-property-for-tags
cperl-use-syntax-table-text-property
"*Non-nil means: set up and use `syntax-table' text property generating TAGS."
:type 'boolean
:group 'cperl)
:group 'cperl-speed)
(defcustom cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\)$"
"*Regexp to match files to scan when generating TAGS."
......@@ -300,18 +353,61 @@ Older version of this page was called `perl5', newer `perl'."
"*Indentation used when beautifying regexps.
If `nil', the value of `cperl-indent-level' will be used."
:type '(choice integer (const nil))
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-indent-left-aligned-comments t
"*Non-nil means that the comment starting in leftmost column should indent."
:type 'boolean
:group 'cperl)
:group 'cperl-indentation-details)
(defcustom cperl-under-as-char t
"*Non-nil means that the _ (underline) should be treated as word char."
:type 'boolean
:group 'cperl)
(defcustom cperl-extra-perl-args ""
"*Extra arguments to use when starting Perl.
Currently used with `cperl-check-syntax' only."
:type 'string
:group 'cperl)
(defcustom cperl-message-electric-keyword t
"*Non-nil means that the `cperl-electric-keyword' prints a help message."
:type 'boolean
:group 'cperl-help-system)
(defcustom cperl-indent-region-fix-constructs 1
"*Amount of space to insert between `}' and `else' or `elsif'
in `cperl-indent-region'. Set to nil to leave as is. Values other
than 1 and nil will probably not work."
:type '(choice (const nil) (const 1))
:group 'cperl-indentation-details)
(defcustom cperl-break-one-line-blocks-when-indent t
"*Non-nil means that one-line if/unless/while/until/for/foreach BLOCKs
need to be reformated into multiline ones when indenting a region."
:type 'boolean
:group 'cperl-indentation-details)
(defcustom cperl-fix-hanging-brace-when-indent t
"*Non-nil means that BLOCK-end `}' may be put on a separate line
when indenting a region.
Braces followed by else/elsif/while/until are excepted."
:type 'boolean
:group 'cperl-indentation-details)
(defcustom cperl-merge-trailing-else t
"*Non-nil means that BLOCK-end `}' followed by else/elsif/continue
may be merged to be on the same line when indenting a region."
:type 'boolean
:group 'cperl-indentation-details)
(defcustom cperl-syntaxify-by-font-lock nil
"*Non-nil means that CPerl uses `font-lock's routines for syntaxification.
Not debugged yet."
:type 'boolean
:group 'cperl-speed)
;;; Short extra-docs.
......@@ -321,6 +417,8 @@ If `nil', the value of `cperl-indent-level' will be used."
ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
and/or
ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
Subdirectory `cperl-mode' may contain yet newer development releases and/or
patches to related files.
Get support packages choose-color.el (or font-lock-extra.el before
19.30), imenu-go.el from the same place. \(Look for other files there
......@@ -353,16 +451,15 @@ Before reporting (non-)problems look in the problem section on what I
know about them.")
(defvar cperl-problems 'please-ignore-this-line
"Emacs has a _very_ restricted syntax parsing engine.
"Emacs had a _very_ restricted syntax parsing engine (until RMS's Emacs
20.1).
It may be corrected on the level of C code, please look in the
`non-problems' section if you want to volunteer.
CPerl mode tries to corrects some Emacs misunderstandings, however,
for efficiency reasons the degree of correction is different for
different operations. The partially corrected problems are: POD
sections, here-documents, regexps. The operations are: highlighting,
indentation, electric keywords, electric braces.
Even with older Emacsen CPerl mode tries to corrects some Emacs
misunderstandings, however, for efficiency reasons the degree of
correction is different for different operations. The partially
corrected problems are: POD sections, here-documents, regexps. The
operations are: highlighting, indentation, electric keywords, electric
braces.
This may be confusing, since the regexp s#//#/#\; may be highlighted
as a comment, but it will be recognized as a regexp by the indentation
......@@ -375,14 +472,23 @@ ${aaa} look like unbalanced braces. The only trick I can think of is
to insert it as $ {aaa} (legal in perl5, not in perl4).
Similar problems arise in regexps, when /(\\s|$)/ should be rewritten
as /($|\\s)/. Note that such a transposition is not always possible
:-(. " )
as /($|\\s)/. Note that such a transposition is not always possible.
The solution is to upgrade your Emacs. Note that RMS's 20.2 has some
bugs related to `syntax-table' text properties. Patches are available
on the main CPerl download site, and on CPAN.
If these bugs cannot be fixed on your machine (say, you have an inferior
environment and cannot recompile), you may still disable all the fancy stuff
via `cperl-use-syntax-table-text-property'." )
(defvar cperl-non-problems 'please-ignore-this-line
"As you know from `problems' section, Perl syntax is too hard for CPerl.
"As you know from `problems' section, Perl syntax is too hard for CPerl on
older Emacsen.
Most the time, if you write your own code, you may find an equivalent
\(and almost as readable) expression.
Most of the time, if you write your own code, you may find an equivalent
\(and almost as readable) expression (what is discussed below is usually
not relevant on newer Emacsen, since they can do it automatically).
Try to help CPerl: add comments with embedded quotes to fix CPerl
misunderstandings about the end of quotation:
......@@ -392,19 +498,21 @@ $a='500$'; # ';
You won't need it too often. The reason: $ \"quotes\" the following
character (this saves a life a lot of times in CPerl), thus due to
Emacs parsing rules it does not consider tick (i.e., ' ) after a
dollar as a closing one, but as a usual character.
dollar as a closing one, but as a usual character. This is usually
correct, but not in the above context.
Now the indentation code is pretty wise. The only drawback is that it
relies on Emacs parsing to find matching parentheses. And Emacs
*cannot* match parentheses in Perl 100% correctly. So
Even with older Emacsen the indentation code is pretty wise. The only
drawback is that it relied on Emacs parsing to find matching
parentheses. And Emacs *could not* match parentheses in Perl 100%
correctly. So
1 if s#//#/#;
will not break indentation, but
would not break indentation, but
1 if ( s#//#/# );
will.
would. Upgrade.
By similar reasons
s\"abc\"def\";
will confuse CPerl a lot.
would confuse CPerl a lot.
If you still get wrong indentation in situation that you think the
code should be able to parse, try:
......@@ -412,10 +520,8 @@ code should be able to parse, try:
a) Check what Emacs thinks about balance of your parentheses.
b) Supply the code to me (IZ).
Pods are treated _very_ rudimentally. Here-documents are not treated
at all (except highlighting and inhibiting indentation). (This may
change some time. RMS approved making syntax lookup recognize text
attributes, but volunteers are needed to change Emacs C code.)
Pods were treated _very_ rudimentally. Here-documents were not
treated at all (except highlighting and inhibiting indentation). Upgrade.
To speed up coloring the following compromises exist:
a) sub in $mypackage::sub may be highlighted.
......@@ -425,7 +531,10 @@ To speed up coloring the following compromises exist:
Imenu in 19.31 is broken. Set `imenu-use-keymap-menu' to t, and remove
`car' before `imenu-choose-buffer-index' in `imenu'.
")
`imenu-add-to-menubar' in 20.2 is broken.
Most things on XEmacs are broken too, judging by bug reports I recieve.
Note that some releases of XEmacs are better than the others as far as bugs
reports I see are concerned.")
(defvar cperl-praise 'please-ignore-this-line
"RMS asked me to list good things about CPerl. Here they go:
......@@ -468,7 +577,7 @@ voice);
namespaces in Perl have different colors);
i) Can construct TAGS basing on its knowledge of Perl syntax,
the standard menu has 6 different way to generate
TAGS (if by directory, .xs files - with C-language
TAGS (if \"by directory\", .xs files - with C-language
bindings - are included in the scan);
j) Can build a hierarchical view of classes (via imenu) basing
on generated TAGS file;
......@@ -479,20 +588,75 @@ voice);
to be not so bothering). Electric parentheses behave
\"as they should\" in a presence of a visible region.
l) Changes msb.el \"on the fly\" to insert a group \"Perl files\";
m) Can convert from
if (A) { B }
to
B if A;
5) The indentation engine was very smart, but most of tricks may be
not needed anymore with the support for `syntax-table' property. Has
progress indicator for indentation (with `imenu' loaded).
6) Indent-region improves inline-comments as well;
6) Indent-region improves inline-comments as well; also corrects
whitespace *inside* the conditional/loop constructs.
7) Fill-paragraph correctly handles multi-line comments;
8) Can switch to different indentation styles by one command, and restore
the settings present before the switch.
9) When doing indentation of control constructs, may correct
line-breaks/spacing between elements of the construct.
")
(defvar cperl-speed 'please-ignore-this-line
"This is an incomplete compendium of what is available in other parts
of CPerl documentation. (Please inform me if I skept anything.)
There is a perception that CPerl is slower than alternatives. This part
of documentation is designed to overcome this misconception.
*By default* CPerl tries to enable the most comfortable settings.
From most points of view, correctly working package is infinitely more
comfortable than a non-correctly working one, thus by default CPerl
prefers correctness over speed. Below is the guide how to change
settings if your preferences are different.
A) Speed of loading the file. When loading file, CPerl may perform a
scan which indicates places which cannot be parsed by primitive Emacs
syntax-parsing routines, and marks them up so that either
A1) CPerl may work around these deficiencies (for big chunks, mostly
PODs and HERE-documents), or
A2) On capable Emaxen CPerl will use improved syntax-handlings
which reads mark-up hints directly.
The scan in case A2 is much more comprehensive, thus may be slower.
User can disable syntax-engine-helping scan of A2 by setting
`cperl-use-syntax-table-text-property'
variable to nil (if it is set to t).
One can disable the scan altogether (both A1 and A2) by setting
`cperl-pod-here-scan'
to nil.
B) Speed of editing operations.
One can add a (minor) speedup to editing operations by setting
`cperl-use-syntax-table-text-property'
variable to nil (if it is set to t). This will disable
syntax-engine-helping scan, thus will make many more Perl
constructs be wrongly recognized by CPerl, thus may lead to
wrongly matched parentheses, wrong indentation, etc.
")
;;; Portability stuff:
(defconst cperl-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version))
(defmacro cperl-define-key (emacs-key definition &optional xemacs-key)
(` (define-key cperl-mode-map
(, (if xemacs-key
......@@ -508,13 +672,13 @@ progress indicator for indentation (with `imenu' loaded).
(and (vectorp cperl-del-back-ch) (= (length cperl-del-back-ch) 1)
(setq cperl-del-back-ch (aref cperl-del-back-ch 0)))
(defun cperl-mark-active () (mark)) ; Avoid undefined warning
(if cperl-xemacs-p
(progn
;; "Active regions" are on: use region only if active
;; "Active regions" are off: use region unconditionally
(defun cperl-use-region-p ()
(if zmacs-regions (mark) t))
(defun cperl-mark-active () (mark)))
(if zmacs-regions (mark) t)))
(defun cperl-use-region-p ()
(if transient-mark-mode mark-active t))
(defun cperl-mark-active () mark-active))
......@@ -522,14 +686,15 @@ progress indicator for indentation (with `imenu' loaded).
(defsubst cperl-enable-font-lock ()
(or cperl-xemacs-p window-system))
(defun cperl-putback-char (c) ; Emacs 19
(set 'unread-command-events (list c))) ; Avoid undefined warning
(if (boundp 'unread-command-events)
(if cperl-xemacs-p
(defun cperl-putback-char (c) ; XEmacs >= 19.12
(setq unread-command-events (list (character-to-event c))))
(defun cperl-putback-char (c) ; Emacs 19
(setq unread-command-events (list c))))
(setq unread-command-events (list (eval '(character-to-event c))))))
(defun cperl-putback-char (c) ; XEmacs <= 19.11
(setq unread-command-event (character-to-event c))))
(set 'unread-command-event (eval '(character-to-event c))))) ; Avoid warnings
(or (fboundp 'uncomment-region)
(defun uncomment-region (beg end)
......@@ -551,6 +716,15 @@ progress indicator for indentation (with `imenu' loaded).
:type 'hook
:group 'cperl)
(defvar cperl-syntax-state nil)
(defvar cperl-syntax-done-to nil)
;; Make customization possible "in reverse"
(defsubst cperl-val (symbol &optional default hairy)
(cond
((eq (symbol-value symbol) 'null) default)
(cperl-hairy (or hairy t))
(t (symbol-value symbol))))
;;; Probably it is too late to set these guys already, but it can help later:
......@@ -567,6 +741,18 @@ progress indicator for indentation (with `imenu' loaded).
(condition-case nil
(require 'easymenu)
(error nil))
(condition-case nil
(require 'etags)
(error nil))
(condition-case nil
(require 'timer)
(error nil))
(condition-case nil
(require 'man)
(error nil))
(condition-case nil
(require 'info)
(error nil))
;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
;; macros instead of defsubsts don't work on Emacs, so we do the
;; expansion manually. Any other suggestions?
......@@ -574,7 +760,24 @@ progress indicator for indentation (with `imenu' loaded).
window-system)
(require 'font-lock))
(require 'cl)
))
;; Avoid warning (tmp definitions)
(or (fboundp 'x-color-defined-p)
(defalias 'x-color-defined-p
(cond ((fboundp 'color-defined-p) 'color-defined-p)
;; XEmacs >= 19.12