jrockway / cperl-mode Goto Github PK
View Code? Open in Web Editor NEWcperl-mode with 5.10 fixes, mx-declare support, perl6 support, etc.
cperl-mode with 5.10 fixes, mx-declare support, perl6 support, etc.
cperl-mode This repository is no longer an official one. It only serves as archive for unofficial cperl-mode variants in the past. Please contribute changes to the `lisp/progmodes/cperl-mode.el` file in the official GNU Emacs repository: * http://savannah.gnu.org/projects/emacs You can view a history of its cperl-mode here: * http://git.savannah.gnu.org/cgit/emacs.git/log/?qt=grep&q=cperl-mode.el
Hi
I have emacs 26.3 running on windows with cperl-mode 6.2 from your last commit on this repo.
I have the following configuration :
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq cperl-indent-level 4)
(setq cperl-indent-parens-as-block t)
(setq cperl-close-paren-offset -4)
(setq cperl-continued-statement-offset 4)
(setq cperl-tab-always-indent t)
(setq cperl-fix-hanging-brace-when-indent t)
(setq cperl-indent-subs-specially nil)
When I initialize an array with qw(), it give me the following indent :
my @toto = qw(
toto
tutu
);
Same for :
my @tutu = qw[
tata
titi
];
or even :
use constant CR => qw(
87800
76400
80200
81000
);
This is not my guideline. Is it a normal behavior or a bug ? Is there a variable which take care of this case ?
What I would like should be :
my @toto = qw(
toto
tutu
);
and
my @tutu = qw[
tata
titi
];
and
use constant CR => qw(
87800
76400
80200
81000
);
I started emacs a week ago, I am not fluent enough in elisp to find a fix myself ATM.
open a new file and add subroutine:
sub print_foo {
}
sub foo {
}
Hi,
How do I configure cperl (or is it possible?) so that cperl-indent-region
does not mess up the indentations within here-docs.
If I have something like,
print FILEHANDLE <<EOF;
$i : begin
\$display("");
`INFO1("abcd");
config_this (
.abc(abcd));
EOF
, after cperl indentation it becomes this,
print FILEHANDLE <<EOF;
$i : begin
\$display("");
`INFO1("abcd");
config_this (
.abc(abcd));
EOF
How do I prevent that?
I am using cperl version 20140309.122 from Melpa.
Thanks.
.t
scripts are Perl, too!
Using the latest here, typing q(a string) does not highlight the 'q'. Ditto qx,qr, etc. Putting a space in there, i.e. q (a string) highlights the q. I tried to figure out where it's happening but to no avail. What's even worse is that 18 months ago, I DID figure it out and fix it, but I left that code at an old job and I'm not sure now if I fixed this version or the one in the SUMO or the one that is embedded in XEmacs proper. Any idea where I can start looking so I can try to reproduce my fix?
patch:
3204c3204,3206
< (cond ((boundp 'compilation-error-regexp-alist-alist);; xemacs 20.x
---
> (cond ((and
> (boundp 'compilation-error-regexp-alist-alist);; xemacs 20.x
> (boundp 'compilation-build-compilation-error-regexp-alist))
Hello I want to write code blocks alike following:
xxx {
yyy
}
I saw this
(defcustom cperl-indent-parens-as-block nil
"*Non-nil means that non-block ()-, {}- and []-groups are indented as blocks,
but for trailing \",\" inside the group, which won't increase indentation.
One should tune up `cperl-close-paren-offset' as well."
:type 'boolean
:group 'cperl-indentation-details)
And was trying to add this:
(setq cperl-indent-parens-as-block t)
https://github.com/Cynede/emacs.d/commit/a93298c882dbd5170636df7c7e53711bb1b94ba0
I expected it will indent closing block bracket but it doesn't. And I can't detect any other changes.
When I set
(defcustom cperl-indent-parens-as-block t
...
in code it doesn't indent closing block bracket too.
When a slash operator is encountered on a buffer line, the next line will be indented from first symbol and the indentation of following lines will break:
sub foo {
...
__my $password_exp = \["= encode(digest(?, 'sha1'), 'hex')", $password . $self->ctx->app->secret];
return $self->find({ login => $username, password => $password_exp }, { key => 'uniq_login-password' });
}
The expected behavior is that the next and following line indented properly.
It seems cperl-mode triggers this error whenever I hit C-s and swiper.el runs for the first time in a buffer. I am not sure this is actually caused by cperl or swiper.el but my backtrace looks like this:
error("No match %d in highlight %S" 4 (4 font-lock-variable-name-face))
font-lock-fontify-keywords-region(1545 95809 nil)
font-lock-default-fontify-region(1545 95809 nil)
cperl-font-lock-fontify-region-function(1545 95809 nil)
font-lock-fontify-region(1545 95809)
#f(compiled-function (fun) #<bytecode 0x19b684bedeca5dbd>)(font-lock-fontify-region)
jit-lock--run-functions(1545 95809)
jit-lock-fontify-now(1 95809)
font-lock-ensure()
swiper-font-lock-ensure()
swiper--candidates()
swiper()
funcall-interactively(swiper)
command-execute(swiper)
So the error is at least triggered downstream from "cperl-font-lock-fontify-region-function" which is why I am posting it here.
After installing cperl mode from stable melpa I get crash (full backtrace below) after pressing '{' key (or any other electric key). Emacs 24.3.1.
If I see correctly, that is fixed in current code (the problem is last-command-char => last-command-event migration), so the only thing necessary to fix is to make stable release (= tag 6.3 or 7.0).
Would you mind?
Debugger entered--Lisp error: (void-variable last-command-char)
(eq last-command-char 125)
(and (eq last-command-char 125) (not (condition-case nil (save-excursion (up-list (- (prefix-numeric-value arg))) (or (cperl-after-expr-p nil "{;)") (cperl-after-block-p nil (quote pre)))) (error nil))))
(if (and (eq last-command-char 125) (not (condition-case nil (save-excursion (up-list (- (prefix-numeric-value arg))) (or (cperl-after-expr-p nil "{;)") (cperl-after-block-p nil (quote pre)))) (error nil)))) (self-insert-command (prefix-numeric-value arg)) (if (and (not arg) (eolp) (or (and (null only-before) (save-excursion (skip-chars-backward " ") (bolp))) (and (eq last-command-char 123) (not cperl-extra-newline-before-brace) (save-excursion (skip-chars-backward " ") (eq (preceding-char) 41))) (if cperl-auto-newline (progn (cperl-indent-line) (newline) t) nil))) (progn (self-insert-command (prefix-numeric-value arg)) (cperl-indent-line) (if cperl-auto-newline (setq insertpos (1- (point)))) (if (and cperl-auto-newline (null only-before)) (progn (newline) (cperl-indent-line))) (save-excursion (if insertpos (progn (goto-char insertpos) (search-forward (make-string 1 last-command-char)) (setq insertpos (1- ...)))) (delete-char -1)))) (if insertpos (save-excursion (goto-char insertpos) (self-insert-command (prefix-numeric-value arg))) (self-insert-command (prefix-numeric-value arg))))
(if (and other-end (not cperl-brace-recursing) (cperl-val (quote cperl-electric-parens)) (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))) (progn (save-excursion (setq insertpos (point-marker)) (goto-char other-end) (setq last-command-char 123) (cperl-electric-lbrace arg insertpos)) (forward-char 1)) (if (and (eq last-command-char 125) (not (condition-case nil (save-excursion (up-list (- ...)) (or (cperl-after-expr-p nil "{;)") (cperl-after-block-p nil ...))) (error nil)))) (self-insert-command (prefix-numeric-value arg)) (if (and (not arg) (eolp) (or (and (null only-before) (save-excursion (skip-chars-backward " ") (bolp))) (and (eq last-command-char 123) (not cperl-extra-newline-before-brace) (save-excursion (skip-chars-backward " ") (eq ... 41))) (if cperl-auto-newline (progn (cperl-indent-line) (newline) t) nil))) (progn (self-insert-command (prefix-numeric-value arg)) (cperl-indent-line) (if cperl-auto-newline (setq insertpos (1- (point)))) (if (and cperl-auto-newline (null only-before)) (progn (newline) (cperl-indent-line))) (save-excursion (if insertpos (progn (goto-char insertpos) (search-forward ...) (setq insertpos ...))) (delete-char -1)))) (if insertpos (save-excursion (goto-char insertpos) (self-insert-command (prefix-numeric-value arg))) (self-insert-command (prefix-numeric-value arg)))))
(let (insertpos (other-end (if (and cperl-electric-parens-mark (cperl-mark-active) (< (mark) (point))) (mark) nil))) (if (and other-end (not cperl-brace-recursing) (cperl-val (quote cperl-electric-parens)) (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))) (progn (save-excursion (setq insertpos (point-marker)) (goto-char other-end) (setq last-command-char 123) (cperl-electric-lbrace arg insertpos)) (forward-char 1)) (if (and (eq last-command-char 125) (not (condition-case nil (save-excursion (up-list ...) (or ... ...)) (error nil)))) (self-insert-command (prefix-numeric-value arg)) (if (and (not arg) (eolp) (or (and (null only-before) (save-excursion ... ...)) (and (eq last-command-char 123) (not cperl-extra-newline-before-brace) (save-excursion ... ...)) (if cperl-auto-newline (progn ... ... t) nil))) (progn (self-insert-command (prefix-numeric-value arg)) (cperl-indent-line) (if cperl-auto-newline (setq insertpos (1- ...))) (if (and cperl-auto-newline (null only-before)) (progn (newline) (cperl-indent-line))) (save-excursion (if insertpos (progn ... ... ...)) (delete-char -1)))) (if insertpos (save-excursion (goto-char insertpos) (self-insert-command (prefix-numeric-value arg))) (self-insert-command (prefix-numeric-value arg))))))
cperl-electric-brace(nil)
(let ((cperl-brace-recursing t) (cperl-auto-newline cperl-auto-newline) (other-end (or end (if (and cperl-electric-parens-mark (cperl-mark-active) (> (mark) (point))) (save-excursion (goto-char (mark)) (point-marker)) nil))) pos after) (and (cperl-val (quote cperl-electric-lbrace-space)) (eq (preceding-char) 36) (save-excursion (skip-chars-backward "$") (looking-at "\\(\\$\\$\\)*\\$\\([^\\$]\\|$\\)")) (insert 32)) (if (and (save-excursion (beginning-of-line) (not (looking-at "[ ]*#"))) (cperl-after-expr-p nil "{;)")) nil (setq cperl-auto-newline nil)) (cperl-electric-brace arg) (and (cperl-val (quote cperl-electric-parens)) (eq last-command-char 123) (memq last-command-char (append cperl-electric-parens-string nil)) (or (if other-end (goto-char (marker-position other-end))) t) (setq last-command-char 125 pos (point)) (progn (cperl-electric-brace arg t) (goto-char pos))))
cperl-electric-lbrace(nil)
call-interactively(cperl-electric-lbrace nil nil)
PS stable melpa offers cperl-mode 6.2 as this is newest existing tag.
When writing embedded perldoc in a perl module, sometimes (about half the time), Emacs hangs with 100% CPU usage. Here is an example:
=head2 test
=cut
=head3 test
If I type the preceding lines into an empty perl file in cperl mode, about half the time Emacs will hang right after I press Enter at the end of the head3 line. Pressing CTRL-g seems to fix the problem.
I tried setting Debug on CTRL-g and I got this backtrace after unfreezing with CTRL-g:
Debugger entered--Lisp error: (quit)
cperl-unwind-to-safe(t 32)
cperl-fontify-syntaxically(32)
cperl-update-syntaxification(32 32)
cperl-sniff-for-indent(nil)
cperl-calculate-indent(nil)
cperl-indent-line()
indent-according-to-mode()
(if (not evil-auto-indent) (newline count) (delete-horizontal-space t) (newline count) (indent-according-to-mode))
(cond ((and widget (fboundp (quote widget-type)) (fboundp (quote widget-button-press)) (or (and (symbolp widget) (get widget (quote widget-type))) (and (consp widget) (get (widget-type widget) (quote widget-type))))) (if (evil-operator-state-p) (progn (setq evil-inhibit-operator t))) (if (fboundp (quote widget-button-press)) (progn (widget-button-press (point))))) ((and (fboundp (quote button-at)) (fboundp (quote push-button)) (button-at (point))) (if (evil-operator-state-p) (progn (setq evil-inhibit-operator t))) (push-button)) ((or (evil-emacs-state-p) (and (evil-insert-state-p) (not buffer-read-only))) (if (not evil-auto-indent) (newline count) (delete-horizontal-space t) (newline count) (indent-according-to-mode))) (t (evil-next-line count)))
(let* ((field (get-char-property (point) (quote field))) (button (get-char-property (point) (quote button))) (doc (get-char-property (point) (quote widget-doc))) (widget (or field button doc))) (cond ((and widget (fboundp (quote widget-type)) (fboundp (quote widget-button-press)) (or (and (symbolp widget) (get widget (quote widget-type))) (and (consp widget) (get (widget-type widget) (quote widget-type))))) (if (evil-operator-state-p) (progn (setq evil-inhibit-operator t))) (if (fboundp (quote widget-button-press)) (progn (widget-button-press (point))))) ((and (fboundp (quote button-at)) (fboundp (quote push-button)) (button-at (point))) (if (evil-operator-state-p) (progn (setq evil-inhibit-operator t))) (push-button)) ((or (evil-emacs-state-p) (and (evil-insert-state-p) (not buffer-read-only))) (if (not evil-auto-indent) (newline count) (delete-horizontal-space t) (newline count) (indent-according-to-mode))) (t (evil-next-line count))))
(save-restriction (if (and (not (evil-operator-state-p)) (not (eobp)) (save-excursion (goto-char (point-max)) (bolp))) (progn (evil-narrow nil (1- (point-max))))) (let* ((field (get-char-property (point) (quote field))) (button (get-char-property (point) (quote button))) (doc (get-char-property (point) (quote widget-doc))) (widget (or field button doc))) (cond ((and widget (fboundp (quote widget-type)) (fboundp (quote widget-button-press)) (or (and (symbolp widget) (get widget ...)) (and (consp widget) (get ... ...)))) (if (evil-operator-state-p) (progn (setq evil-inhibit-operator t))) (if (fboundp (quote widget-button-press)) (progn (widget-button-press (point))))) ((and (fboundp (quote button-at)) (fboundp (quote push-button)) (button-at (point))) (if (evil-operator-state-p) (progn (setq evil-inhibit-operator t))) (push-button)) ((or (evil-emacs-state-p) (and (evil-insert-state-p) (not buffer-read-only))) (if (not evil-auto-indent) (newline count) (delete-horizontal-space t) (newline count) (indent-according-to-mode))) (t (evil-next-line count)))))
evil-ret(nil)
call-interactively(evil-ret nil nil)
Hello, everything is in the title ;-)
Regards.
Thanks for maintaining this package.
Any plans on syntax highlight for signatures? (as in, experimental::signatures)
Scalars with package prefixes are not correctly highlighted ($Some::Package::var). Something like this should fix it:
--- cperl-mode.el 2011-06-29 18:36:02.643056200 +0200 +++ elisp/cperl-mode.el 2011-06-29 17:10:04.027108889 +0200 @@ -5934,7 +5934,7 @@ (if cperl-highlight-variables-indiscriminately (setq t-font-lock-keywords-1 (append t-font-lock-keywords-1 - (list '("\\([$*]{?\\sw+\\)" 1 + (list '("\\([$*]{?[[:alnum:]_:]+\\)" 1 font-lock-variable-name-face))))) (setq cperl-font-lock-keywords-1 (if cperl-syntaxify-by-font-lock
Using the test file below with the cursor located at |
try to type the m character.
#!/usr/bin/perl
|
my $foo;
You will see the error End of โmp ... pโ string/RE not found: (scan-error Unbalanced parentheses n n)
#49 compiles without problems. The minimal set of changes needed seems to be
modified cperl-mode.el
@@ -1011,7 +1011,7 @@ In regular expressions (except character classes):
unrecognized escape sequences
`cperl-nonoverridable-face' Modifiers, as gism in m/REx/gism
`font-lock-type-face' POSIX classes inside charclasses,
- escape sequences with arguments (\x \23 \p \N)
+ escape sequences with arguments (\\x \\23 \\p \\N)
and others match-a-char escape sequences
`font-lock-keyword-face' Capturing parens, and |
`font-lock-function-name-face' Special symbols: $ ^ . [ ] [^ ] (?{ }) (??{ })
@@ -2189,8 +2189,8 @@ See `cperl-electric-parens'."
(insert (make-string
(prefix-numeric-value arg)
(cdr (assoc last-command-event '((?{ .?})
- (?[ . ?])
- (?( . ?))
+ (?\[ . ?\])
+ (?\( . ?\))
(?< . ?>))))))
(forward-char (- (prefix-numeric-value arg))))
(self-insert-command (prefix-numeric-value arg)))))
it takes 's+' as starting of substitution and wants another '+'
I am using branch mxd-perl6-merge
=snip for testing=
#!/usr/bin/env perl use strict; my $string; my $x = split /\s+/, $string; # morestuff my $nowaycolor;
== end snp==
Follow-up to #39.
gets an error compiling (on GNU Emacs 23 at least)
see: http://old.nabble.com/"Error:-Non-hex-digit-used-for-Unicode-escape"-td4982561.html
Also affects this version.
Looks like an oversight. I see merges in the history from 6.2. Should be 6.2.1 or something to differentiate between official releases and mark your own incremental releases.
As reported here, "a bunch of regressions on Perl 5 syntax that seemingly have to do with broken precedence rules":
I've merged the changes from this repository's master branch into Emacs's master branch. And I also installed various other cleanups into Emacs's master branch (e.g. to use lexical-binding and solve the many resulting warnings).
Missing \ before | in emacs regex:
cperl-mode.el~ 2011-07-01 00:46:25.000000000 +0200 cperl-mode.el 2011-07-02 22:01:56.000000000 +0200 @@ -5761,7 +5761,7 @@ ;; "sort" "splice" "split" "state" "study" "sub" "tie" "tr" ;; "undef" "unless" "unshift" "untie" "until" "use" ;; "when" "while" "y" - "AUTOLOAD\\|BEGIN\\|\\(UNIT\\)?CHECK\\|break\\|cho\\(p\\|mp\\)\\|d\\(e\\(f\\(ault|ined\\)\\|lete\\)\\|" + "AUTOLOAD\\|BEGIN\\|\\(UNIT\\)?CHECK\\|break\\|cho\\(p\\|mp\\)\\|d\\(e\\(f\\(ault\\|ined\\)\\|lete\\)\\|" "o\\)\\|DESTROY\\|e\\(ach\\|val\\|xists\\|ls\\(e\\|if\\)\\)\\|" "END\\|for\\(\\|each\\|mat\\)\\|g\\(iven\\|rep\\|oto\\)\\|INIT\\|if\\|keys\\|" "l\\(ast\\|ocal\\)\\|m\\(ap\\|y\\)\\|n\\(ext\\|o\\)\\|our\\|"
I'm using cperl-mode 6.2 with GNU Emacs 24.5.1 (x86_64-apple-darwin15.0.0, NS apple-appkit-1404.11), using prelude starter kit.
A constant block like this:
use constant {
ONE => 1,
TWO => 2
};
is formatted like this by cperl:
use constant {
ONE => 1,
TWO => 2
};
I have the following settings:
(defun my-cperl-mode-defaults ()
(setq cperl-close-paren-offset -2
cperl-close-brace-offset -2
cperl-continued-statement-offset 2
cperl-continued-brace-offset 2
cperl-fix-hanging-brace-when-indent t
cperl-indent-level 2
cperl-indent-parens-as-block t
cperl-tabs-always-indent t)
(setq cperl-hairy)
)
(setq prelude-cperl-mode-hook 'my-cperl-mode-defaults)
(add-hook 'cperl-mode-hook (lambda ()
(run-hooks 'prelude-cperl-mode-hook)) t)
This problem seems to have been noted here.
Has it been fixed in a later version? Is there a workaround?
Thanks!
The message in cperl-tips about getting new versions points to Ilya Z's web page. It should presumably point to this site, or even better, a suitable ELPA.
Steps to reproduce:
(cperl-info-on-command "shift")
search-failed "^-X[ ]"
*info* (perl) perlfunc
but not at the right function, and*info-perl* (dir) Top
Somehow the switcheroo in cperl-info-buffer
doesn't get it right
Just open a Perl source in Emacs with cperl-mode and try to create tags with M-x cperl-etags
, and you get the error
(wrong-type-argument stringp cperl-sub-regexp)
.
Looking at the source code reveals: In this particular case, "sub"
can't be replaced by inserting cperl-sub-regexp
: 1) the list as a whole is quoted, so the symbol is passed "as is" to call-process
(causing the error), and 2) unlike with other occurrences of cperl-sub-regexp
, the regexp here isn't concatenated from components, so the argument list to etags would be invalid anyway.
That piece of code has also been already merged into the master branch of emacs (so also broken there). Do you synchronize with patches over there - or is it the other way around?
When inside a cperl HERE doc, using any function that inserts a newline at the start of a line will causes the rest of the file to highlighted with font-lock-comment-face
. The only way to fix this is to make changes to the correctly highlighted part of the HERE doc which causes it to re-parse. My guess is that cperl is getting mixed up with POD highlighting and trying to apply cperl-pod-face
since POD's and HERE documents are very closely related in cperl-mode
code.
To reproduce:
have a cperl-mode
file that looks like such
#!/usr/bin/env perl
my $here_doc = <<'_HERE_';
this is here doc line
| <-- call `Eval: (insert "\n")` when cursor is here or at the start of any line
_HERE_
You will see that the rest of the file is highlighted with the comment face. Calling any function that finds the HERE doc region will be incorrect (e.g. cperl-narrow-to-here-doc
). I have already confirmed that this bug exists in stock Emacs 25.1 as well.
Is it sync'd with the last version but with additional features? The master
branch does not appear to be synchronised.
With cperl-electric-keywords set, when typing if + space I get an expanded construct like this (_ is point):
if ( _) {
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.