prettier / prettier-emacs

Minor mode to format JS code on file save

Home Page:http://jlongster.com/A-Prettier-Formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Saving file loses code from yank buffer

Swizec opened this issue · comments

When I yank code (C-w) and save the file, it clears my yank buffer so I can't paste said code in a different file.

Steps to reproduce:

  1. Have JavaScript
  2. Mark some code
  3. C-w
  4. C-x C-s
  5. Open different file
  6. C-y

Observe nothing gets pasted.

My setup:

(require 'prettier-js)
(defun enable-minor-mode (my-pair)
  "Enable minor mode if filename match the regexp.  MY-PAIR is a cons cell (regexp . minor-mode)."
  (if (buffer-file-name)
      (if (string-match (car my-pair) buffer-file-name)
      (funcall (cdr my-pair)))))


(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-hook 'web-mode-hook #'(lambda ()
                            (enable-minor-mode
                             '("\\.jsx?\\'" . prettier-js-mode))))

For full .emacs.d dir you can see here: https://github.com/Swizec/dot.emacs.d

I'm pretty sure this is happening here.

I probably won't be able to take care of this for a while. If this really bothers you, it would be great if you could you give it a try and send a PR 😃

Thanks!

@rcoedo I secretly don't know how ELisp works. I cobble my config together from README files like yours 😃

I can give it a try one or two weekends from now if it annoys me enough. Thanks for finding the line where it happens!

I've been using this patch ☝️ for the past three weeks and it works fine.