【发布时间】:2012-10-24 19:24:26
【问题描述】:
我正在尝试解决不能在当前目录和父目录. 和.. 上调用dired-do-shell-command(绑定到!)的限制。堆栈跟踪粘贴在底部。
我可以定义如下的建议来绕过这个错误:
(defadvice dired-get-filename (before h-no-error-if-not-filep activate)
(ad-set-arg 1 t))
但这会影响对dired-get-filename 的所有调用。我希望它仅在堆栈为dired-do-shell-command -> dired-get-marked-files -> dired-get-filename 时触发。
我能想到的唯一方法如下
- 在建议定义中搜索
(with-output-to-string (backtrace))中的匹配项 - 将周围的建议添加到其他方法以设置一些可以在建议定义中测试的变量。
有更好的方法吗?我想我正在寻找对当前堆栈跟踪的访问作为数据结构而不是来自(backtrace)的字符串
Debugger entered--Lisp error: (error "Cannot operate on `.' or `..'")
signal(error ("Cannot operate on `.' or `..'"))
error("Cannot operate on `.' or `..'")
dired-get-filename(t)
dired-get-marked-files(t nil)
(let ((files (dired-get-marked-files t current-prefix-arg))) (list (dired-read-shell-command (concat "! on " "%s: ") current-prefix-arg files) current-prefix-arg files))
call-interactively(dired-do-shell-command nil nil)
【问题讨论】:
-
对于迟到此 Q&A 的任何人,此问题已提出并已修复 --
dired-do-shell-command在 Emacs 的稳定版本中适用于.和..。
标签: emacs elisp advising-functions defadvice