关于dired批量改名的一个问题请教

如图,想把文件名中曲名后面括号及其内容删除,wdired-change-to-wdired-mode然后 M-X replace-regexp (Av[0-9]+.*) RET RET 提示:

search-backward-lax-whitespace: Invalid search bound (wrong side of point)

改名不成功。

但是如果图中的内容在一个普通文档中时,用上述 replace-regexp 表达式却能准确删除括号及其内容。

这是啥情况?请教 :handshake:

你试试这个小工具,批量改完先

有可能是icon有search bound相关的属性,导致dired buffe实际上被那一排icon分割成了多个不连续的区域,所以修改失败了,可以关了icon再试试

截屏2025-03-21 下午9.58.05

只保留成这样也是报错,网上要求光标位于文件名中什么的试过也是无效。:joy:

我自己在 dired 中创建了一些类似你文件名的文件,是可以通过你给的正则操作的,没有问题。

试试 emacs -Q,会不会是配置的问题?

试试 whitespace-mode 看看是不是有什么奇怪字符?

打开 toggle-debug-on-error提示

Debugger entered--Lisp error: (error "Invalid search bound (wrong side of point)")
  re-search-backward("Av\\[0-9]\\+" 160 t nil)
  search-backward-lax-whitespace(#("Av[0-9]+" 0 8 (ws-butler-chg chg)) 160 t nil)
  search-within-boundaries(search-backward-lax-whitespace #f(compiled-function (pos) #<bytecode 0x15687db0d113b59d>) #f(compiled-function (pos) #<bytecode 0xa8d2a5163c94abb>) #("Av[0-9]+" 0 8 (ws-butler-chg chg)) nil t)
  apply(search-within-boundaries (search-backward-lax-whitespace #f(compiled-function (pos) #<bytecode 0x15687db0d113b59d>) #f(compiled-function (pos) #<bytecode 0xa8d2a5163c94abb>) #("Av[0-9]+" 0 8 (ws-butler-chg chg)) nil t))
  #f(compiled-function (&rest args2) #<bytecode 0xb24ec064d16c763>)(#("Av[0-9]+" 0 8 (ws-butler-chg chg)) nil t)
  replace-search(#("Av[0-9]+" 0 8 (ws-butler-chg chg)) nil t nil nil nil)
  perform-replace(#("Av[0-9]+" 0 8 (ws-butler-chg chg)) "" nil t nil nil nil nil nil nil nil)
  replace-regexp(#("Av[0-9]+" 0 8 (ws-butler-chg chg)) "" nil nil nil nil nil)
  funcall-interactively(replace-regexp #("Av[0-9]+" 0 8 (ws-butler-chg chg)) "" nil nil nil nil nil)
  call-interactively(replace-regexp record nil)
  command-execute(replace-regexp record)
  execute-extended-command(nil "replace-regexp" nil)
  funcall-interactively(execute-extended-command nil "replace-regexp" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

很是发懵 :frowning:

你的怎么不太一样,是不是 .* 被吞了?

另外,emacs -Q 试一试。

emacs -Q 正则可用,应该是配置文件里某处有错,相关dired的都屏蔽了没解决问题,慢慢再找吧。