If I press 'q' in Dired this buries the current buffer. I would prefer to have 'q' kill the buffer. Hence, I would like to bind the command "kill-this-buffer" to 'q' in Dired. Is this possible and advisable?
1 Answer
Is this possible?: Yes.
Is this advisable?: Emacs is meant to be configurable and custom tailored to the needs of each particular user. There is no disadvantage that I am aware of to rebinding the "q" key to something that the O.P. finds more useful.
(require 'dired)
(define-key dired-mode-map "q" 'kill-this-buffer)
-
3More idiomatic would be:
(with-eval-after-load 'dired (define-key dired-mode-map "q" 'kill-this-buffer))
– clemeraCommented Dec 29, 2019 at 19:41 -
"Is this advisable?" The answer is: "probably not" . 'quit-window is bound to "q" and should be left as is. My suggestion to OP is to define another key to 'kill-this-buffer, for instance, the letter "K" is available.– RobertCommented Jan 19, 2021 at 9:46