Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cperl-mode + smartparens issue #480

Closed
alexrkopp-xx opened this issue Jan 25, 2015 · 8 comments
Closed

cperl-mode + smartparens issue #480

alexrkopp-xx opened this issue Jan 25, 2015 · 8 comments
Labels

Comments

@alexrkopp-xx
Copy link

Hello,

If you switch into cperl-mode and type the following:

if (0) {

It will be automatically changed to

if (0) {}}

Note the two closing curly braces. Switching into perl-mode and typing that same line yields proper behavior.

Any ideas?

@alexrkopp-xx
Copy link
Author

Anyone have any idea what is causing this?

@jasonblewis
Copy link

I see this behaviour too. I think its related to smartparens as I don't use spacemacs

@spacebat
Copy link

I think its a conflict between cperl's electric braces and related options, and smartparens' auto pairing. I've disabled all of cperl's electric settings.

@Fuco1
Copy link

Fuco1 commented May 21, 2015

It might very well be what @spacebat describes. Smartparens is quite aggresive in its own enforcing rules, since most of the time the "electric" stuff is quite, well, idiotic. The apparently random order of execution of hooks doesn't help one bit either... it is most recomended to turn off any electric stuff while using SP.

@pasja
Copy link

pasja commented Jun 22, 2015

My quick&dirty solution:
(define-key cperl-mode-map "{" 'nil)

@TheBB
Copy link
Collaborator

TheBB commented Jan 26, 2016

Since Spacemacs doesn't have a layer for this mode, and since there's an easy workaround from @pasja, I am liable to close this. If the time comes when Spacemacs has official Perl support we can revisit.

For future visitors, the workaround should be (in user-config):

(with-eval-after-load 'cperl-mode
  (define-key cperl-mode-map "{" nil))

@TheBB TheBB closed this as completed Jan 26, 2016
@benlind
Copy link

benlind commented Aug 4, 2016

I recently had this problem. I have electric-pair-mode on with cperl-mode, and I was getting {}} when typing { on an empty line.

This solved my problem:

(add-hook 'cperl-mode-hook (lambda () (local-unset-key (kbd "{"))))

@CeleritasCelery
Copy link
Contributor

This solution will allow electric-pair-mode to still work when smartparens is toggled off

(with-eval-after-load 'cperl-mode
  (add-hook 'smartparens-enabled-hook  (lambda () (define-key cperl-mode-map "{" nil)))
  (add-hook 'smartparens-disabled-hook  (lambda () (define-key cperl-mode-map "{" 'cperl-electric-lbrace))))

bcc32 added a commit to bcc32/dotfiles that referenced this issue Oct 30, 2018
Spacemacs develop branch has a perl5 layer now, which includes this workaround.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants