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

crux-rename-file-and-buffer: move file into a different directory, without changing the filename #98

Open
jmay opened this issue Jun 21, 2023 · 0 comments

Comments

@jmay
Copy link

jmay commented Jun 21, 2023

Expected behavior

When I use crux-rename-file-and-buffer, and I select a target directory but don't enter a new filename, then I expect the file to be moved to the new directory with the same filename, and the emacs buffer should track the renamed file, i.e. editing and saving the buffer should update the file in the new location.

Actual behavior

The file is moved to the new directory, but the minibuffer show an error message "Empty file name" and the buffer does not track the new file location.

Steps to reproduce the problem

  • Create a dummy file and dummy subdirectory in the same directory.
  • Visit the file in a buffer
  • Execute crux-rename-file-and-buffer
  • Enter the subdirectory name (or pick it from completion options), but do not type any new file name portion
  • Press enter

Proposed change to support the desired behavior

In crux-rename-file-and-buffer, insert the following as the first line inside the when-let* block:

    (if (string= (file-name-nondirectory new-name) "")
        (setq new-name (concat containing-dir (file-name-nondirectory filename))))

Environment & Version information

crux version information

crux version: 0.4.0

Emacs version

30.0.50 on macOS 13.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant