dired目录的值 [英] Value of the dired-directory

查看:125
本文介绍了dired目录的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在当前缓冲区的位置运行一个脚本,或者如果它是一个可怕的缓冲区,可以在当前的dired目录下运行该脚本。当前dired目录似乎存储在 dired-directory 变量中。确实是 - 但是当我尝试使用它时,它有时会给我以前的目录而不是现在的目录:

I wanted to run a script in the location of the current buffer, or, if it is a dired buffer - to run the script on the current dired directory. The current dired directory seems to be stored in dired-directory variable. Indeed it is - but when I try to make use of it - it sometimes gives me the previous dirs instead of the current one:

(defun bk-konsoles ()
  "Calls: bk-konsoles.bash"
  (interactive)
  (let ((curDir (if (memq major-mode '(dired-mode sr-mode)) dired-directory
                  (if (buffer-file-name) (file-name-directory (buffer-file-name))))))
    (shell-command (concat (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ") curDir " & disown") nil nil)
    (kill-buffer "*Shell Command Output*")
    (delete-other-windows)))

如何让defun获得正确的值dired的当前目录?

How do I make the defun get the right value of the dired's current directory?

推荐答案

可以使用变量 default-directory

在这种情况下,您不需要检查您是否处于dired模式。

In this case you don't need to check if you're in the dired mode or not.

这篇关于dired目录的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆