tuhdo / semantic-refactor

Semantic Refactor is a refactoring tool based on Semantic parser framework
269 stars 25 forks source link

Little bug when formatting elisp #18

Open seanirby opened 8 years ago

seanirby commented 8 years ago

Hey @tuhdo

Thanks for this package.

I'm generating some lisp code programmatically and I need to format it with your tool after I insert it into a buffer. Works great except for this little bug. Not a big deal for me at all, just thought I would let you know:

starting input

(list :directory "/home/vagrant/Dropbox/dev-shared/shorty/album2/" :name "asdf" :minor-modes (list (quote magit-blame-mode) (quote global-linum-mode)) :text-refs (list :asdf "asdf.el") :playlists (list (list :name "playlist1" :demos nil)))

expected output

(list :directory "/home/vagrant/Dropbox/dev-shared/shorty/album2/"
      :name "asdf"
      :minor-modes (list (quote magit-blame-mode)
                         (quote global-linum-mode))
      :text-ref (list :asdf "asdf.el")
      :playlists (list (list :name "playlist1"
                             :demos nil)))

actual output after executing srefactor-lisp-format-sexp at beginning of buffer

(list :directory "/home/vagrant/Dropbox/dev-shared/shorty/album2/"
      :name "asdf"
      :minor-modes (list (quote magit-blame-mode)
                         (quote global-linum-mode)):text-refs
                         (list :asdf "asdf.el")
                         :playlists (list (list :name "playlist1"
                                                :demos nil)))
tuhdo commented 8 years ago

Thanks. I will look into it soon.

matthew-piziak commented 5 years ago

Same here. It doesn't appear to handle property lists well.

(use-package srefactor
  :straight t
  :config (require 'srefactor-lisp)(defun format-emacs-lisp-buffer ()
                     (when (and (eq major-mode 'emacs-lisp-mode)
                        (not (s-equals? ".emacs"
                                (buffer-name))))
                       (srefactor-lisp-format-buffer)))(add-hook 'before-save-hook #'format-emacs-lisp-buffer)(advice-add 'org-edit-src-save :before #'format-emacs-lisp-buffer))
matthew-piziak commented 5 years ago

At minimum it should not glue together multiline expressions without line breaks between them.

matthew-piziak commented 5 years ago

If I change my style and use progn it's okay, but this should not be required.

(use-package srefactor
  :straight t
  :config (progn
        (require 'srefactor-lisp)
        (defun format-emacs-lisp-buffer ()
          (when (and (eq major-mode 'emacs-lisp-mode)
             (not (s-equals? ".emacs"
                     (buffer-name))))
        (srefactor-lisp-format-buffer)))
        (add-hook 'before-save-hook #'format-emacs-lisp-buffer)
        (advice-add 'org-edit-src-save :before #'format-emacs-lisp-buffer)))
ghost commented 4 years ago

If I change my style and use progn it's okay, but this should not be required.

Tried out your snippet and now I have lines over 200 characters long due to my extensive use of use-package configs.

bard commented 3 years ago

A long shot after almost five years, but... did anybody find a workaround?

matthew-piziak commented 3 years ago

@bard I just stopped using srefactor.