我正在尝试解决不能在当前和父目录 上调用
和 dired-do-shell-command
(绑定(bind)到 !
)的限制。 ..
'。堆栈跟踪粘贴在底部。
我可以定义如下的建议来绕过这个错误:
(defadvice dired-get-filename (before h-no-error-if-not-filep activate)
(ad-set-arg 1 t))
但这会影响对 dired-get-filename
的所有调用。 我希望它仅在堆栈为 dired-do-shell- 时触发命令 -> 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)
最佳答案
您可以通过 backtrace-frame
一次访问一层堆栈跟踪。但这确实在插入黑客攻击。我还建议您 M-x report-emacs-bug
请求 !
在 .
和 ..
上工作。
关于emacs - 仅当从某个其他函数调用时才触发对函数的建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13056273/