`citre-update-tags-file` incorrect use `read-file-name` corrupt the project file
lynnux opened this issue · 4 comments
Emacs 29.0.50, win10 64. When I open one file in project, and M-x citre-update-tags-file
, it will prompt me to select the tag file, and then tip me xxx doesn't contain recipe for updating. Edit its recipe?
, and I select yes, the whole file content is replaced by the tag content generate by ctags, it's a disaster!
And I find the code has bug in citre-update-tags-file
: (read-file-name "Tags file: "(citre-tags-file-path))
C-x C-e at this code end, after select tag, this will get the file path of citre-ctags.el
, not the tag path, cause
(read-file-name PROMPT &optional DIR DEFAULT-FILENAME MUSTMATCH
INITIAL PREDICATE)
the DIR
should not be the file path. The other place use read-file-name
some are right, some are wrong. I don't know whether it's a bug in Emacs 29.0.50 or not.
A few thoughts:
C-x C-e at this code end, after select tag, this will get the file path of citre-ctags.el, not the tag path
I guess you did this in citre-ctags.el
? This would make citre
the current project.
I select yes, the whole file content is replaced by the tag content generate by ctags, it's a disaster!
Sounds like your minibuffer completion tool (ivy, selectrum, etc) made your current file the default tag file, and citre then overwrote the file.
To validate these points, I suggest:
- Disable your minibuffer completion package (or more aggressively start with
emacs -Q
and load only citre). - Navigate to your project buffer.
- Evaluate (default keybinding is
M-:
):(citre-tags-file-path)
--> unexpected result indicates a bug in citre.(read-file-name "Tags file: " (citre-tags-file-path))
--> unexpected result indicates a bug in emacs.
Hope it helps.
Thanks a lot for the report and investigation @lynnux @chen-chao ! This should be fixed, please test.
I could confirm the bug. I think this usage works well in Emacs 27 but not Emacs 28. I've recently updated to Emacs 28 and have not tagging any new project since then. Maybe that's why I haven't notice it.