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)))
How do I make the defun get the right value of the dired's current directory?