emacs-evil / evil-surround

you will be surrounded (surround.vim for evil, the extensible vi layer)
Other
632 stars 61 forks source link

surround change remove newline #170

Open Zenoe opened 4 years ago

Zenoe commented 4 years ago

steps to reproduce

  1. open emacs and new a buffer
  2. input
[
blabla  
]
  1. put cursor on [
  2. type c s [ (

the text becomes

( blabla  )

but

(
blabla  
)

is expected

System information evil-surround: 20200603.2216 emacs: "27.0.90" (system (type . gnu/linux) (config . "x86_64-pc-linux-gnu") (shell . "/usr/bin/zsh") (uname . "Linux 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64") )

((emacs
  (version . "27.0.90")
  (features . "SOUND DBUS GSETTINGS GLIB NOTIFY INOTIFY GNUTLS LIBXML2 FREETYPE HARFBUZZ XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS PDUMPER GMP")
  (build . "Apr 11, 2020")
  (buildopts "--without-makeinfo --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no")
  (windowsys . batch)
  (daemonp))
 (doom
  (version . "2.0.9")
  (build . "HEAD -> develop, origin/develop 7615bacde 2020-04-11 00:35:07 -0400")
  (dir . "~/.doom.d/"))
 (system
  (type . gnu/linux)
  (config . "x86_64-pc-linux-gnu")
  (shell . "/usr/bin/zsh")
  (uname . "Linux 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64")
  (path "~/perl5/bin" "~/.nvm/versions/node/v10.16.3/bin" "~/perl5/bin" "/usr/local/sbin" "/usr/local/bin" "/usr/sbin" "/usr/bin" "~/bin" "/usr/local/go/bin" "~/go/bin" "/usr/local/maven3/bin" "/opt/gradle/latest/bin" "/opt/jdk1.8.0_181/bin" "/opt/jdk1.8.0_181/jr
e/bin" "~/.fzf/bin" "~/bin" "/usr/local/go/bin" "~/go/bin" "/usr/local/maven3/bin" "/opt/gradle/latest/bin" "/opt/jdk1.8.0_181/bin" "/opt/jdk1.8.0_181/jre/bin" "/usr/local/libexec/emacs/27.0.90/x86_64-pc-linux-gnu"))
 (config
  (envfile . envvar-file)
  (elc-files . 0)
  (modules :completion company (helm +fuzzy) :ui doom doom-dashboard doom-quit hl-todo modeline nav-flash ophints (popup +all +defaults) vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold multiple-cursors rotate-text
 snippets :emacs dired electric ibuffer vc :tools (eval +overlay) :checkers syntax :tools (lookup +docsets) magit :lang data emacs-lisp javascript markdown (org +dragndrop +present) sh :config (default +bindings +smartparens))
  (packages (xclip) (wgrep))
  (unpin "n/a")
  (elpa "n/a")))

ninrod commented 4 years ago

@Zenoe , thanks for the input.

Did you use make emacs to try to reproduce your issue in a clean environment?

Zenoe commented 4 years ago

@ninrod , sorry I don't quit understand what make emacs means. I use doom emacs.

ninrod commented 4 years ago

@Zenoe

@ninrod , sorry I don't quit understand what make emacs means. I use doom emacs.

No worries, here.

Zenoe commented 4 years ago

@ninrod , I've tried make emacs, it doesn't support evil-surround. I can't find any evil-surround comand. Steps are as follows:

ninrod commented 4 years ago

Did you get any errors after make?

Zenoe commented 4 years ago

I tried make one more time and got no error. However I did get error from make emacs minibuffer: Cannot open load file: No such file or directory, undo-tree.el

ninrod commented 4 years ago

seems like make could not download the undo-tree.el dependency.

Roger-Roger-debug commented 1 month ago

I think the expected behavior would be for there to be a evil-Surround-change command that adds newlines similar to evil-Surround-region. That way the commands could behave like this

[
blabla
]

with cgs[[ -> [ blabla ] and with cgS[[ back to the original.

I thought I could mostly copy the current implementation and change the evil-surround-region call to include a newline, but doing that would add a new newline after each change. Looking a bit further I found out that evil-surround-delete will delete the opening newline, but not the closing. Maybe that's why my approach didn't work? My Elisp knowledge isn't good enough to figure that out on my own though.