drym-org / symex.el

An intuitive way to edit Lisp symbolic expressions ("symexes") structurally in Emacs
Other
272 stars 23 forks source link

Calling symex-replace on string sets the cursor after the string #87

Closed devcarbon-com closed 1 year ago

devcarbon-com commented 1 year ago

Calling symex-replace on string sets the cursor after the string, instead of inside it.

countvajhula commented 1 year ago

I'm not able to reproduce this. In this example:

(concat |"hi" "abc" "ef")

Hitting s for replace results in:

(concat "|" "abc" "ef")

... i.e. positioning the cursor inside the quotes.

Now, after completing the edit, returning to Symex state results in:

(concat "|bye" "abc" "ef")

... with the cursor inside the string instead of outside it like this:

(concat |"bye" "abc" "ef") ; preferable

Is that what you are referring to, or is it behaving differently for you?

If so, anything you can share about your config would be useful. Are you an Evil or vanilla Emacs user?

olnw commented 1 year ago

Calling symex-replace on string sets the cursor after the string, instead of inside it.

I'm also having this issue, and I'm an Evil user. With the above example, this is what happens after calling symex-replace:

(concat |"hi" "abc" "ef") -> (concat ""| "abc" "ef")

Here's a minimal configuration with which I could reproduce the issue, running emacs -Q --load example.el:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

(use-package symex
  :ensure t
  :config (symex-initialize)
  :bind ("s-;" . symex-mode-interface))

Note that I'm building Emacs from master, hence why use-package is already installed.

countvajhula commented 1 year ago

Thank you for verifying the bug! I tried using your minimal config and I still wasn't able to reproduce it, which makes me think it is related to using a newer version of Evil or Emacs. As I'm currently in the middle of making a lot of changes, I hesitate to update any dependencies so that there's only one moving target, and I'll aim to do more testing of this issue when we're closer to 2.0 release time (i.e. weeks).

In the meantime, I've actually simplified the implementation of symex-replace to fix some bugs and also reduce reliance on Evil, which potentially addresses the present issue as well. This is currently in the symex-command-macro branch, soon to be merged to 2.0-integration (the 2.0 release branch). If you are feeling adventurous, you could try this config to use the bleeding edge version:

(use-package symex
  :straight
  (symex
   :type git
   :host github
   :repo "drym-org/symex.el")
   :branch "symex-command-macro"
   :config (symex-initialize))

If it is Evil that's the cause, then the bug should hopefully already be fixed!

Btw, there are tons of improvements in the works that will be merged as they are ready into the 2.0-integration branch. If you want to be the first to try all the cool new stuff (the PR description will note all the improvements -- currently there aren't many already merged..), consider using the 2.0-integration branch for the next few weeks until things land in main (and of course bug reports are appreciated! 😺) Note that 2.0-integration will be relatively stable since things will only be merged there once they've been been tested to some extent, but a branch like symex-command-macro is going to be unstable so I wouldn't recommend staying on any branch other than 2.0-integration (and of course master/ soon to be renamed to main). Did I mention there are tons of improvements coming?? I'm stoked! 😊 🌳 🐿️

devcarbon-com commented 1 year ago

@countvajhula I'll try it out, thanks!

And yes, I'm very much excited for what's ahead with Symex. 😁

devcarbon-com commented 1 year ago

Works in 2.0-integration :D