From Newsgroup: gnu.emacs.help
USEnet <
jvromans@squirrel.nl> writes:
When in dired I use 'R' to rename a file.
Is it possible to insert the current file name in the minibuffer for
editing?
I use the following definition in my init.el, which is more general than your request.
I find it very useful.
(defun my-ins-buffer-file-name (arg)
"Insert the file name of the current buffer into the (mini)buffer.
In a dired buffer use the current file name.
With PREFIX argument give the complete path name."
(interactive "P")
;; We assume that the first entry in the buffer list with a non-nil
;; buffer-file-name is the "real" current buffer, since
;; "(current-buffer)" just returns the minibuffer we're in.
(let ((cbf (buffer-list)) b-f-name)
(while (and cbf
(not (setq b-f-name
(or (buffer-file-name (car cbf))
(with-current-buffer (car cbf)
(or
(and (eq major-mode 'dired-mode)
(dired-get-filename))
(and (memq major-mode '(article-mode group-mode))
group-current)))))))
(setq cbf (cdr cbf)))
(if b-f-name
(insert (if arg b-f-name (file-name-nondirectory b-f-name)))
(beep))))
(global-set-key "\C-cf" 'my-ins-buffer-file-name)
--
Pieter van Oostrum <
pieter@vanoostrum.org>
www:
http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--- Synchronet 3.21d-Linux NewsLink 1.2