• Reuse filename in dired

    From USEnet@jvromans@squirrel.nl to gnu.emacs.help on Fri Nov 3 08:11:45 2023
    From Newsgroup: gnu.emacs.help

    When in dired I use 'R' to rename a file.
    Is it possible to insert the current file name in the minibuffer for
    editing?

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Pieter van Oostrum@pieter-l@vanoostrum.org to gnu.emacs.help on Mon Nov 6 14:36:50 2023
    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
  • From USEnet@jvromans@squirrel.nl to gnu.emacs.help on Mon Nov 6 17:37:58 2023
    From Newsgroup: gnu.emacs.help

    Gut Piet, jij ook nog steeds hier?

    On Mon, 06 Nov 2023 14:36:50 +0100, Pieter van Oostrum wrote:

    I use the following definition in my init.el, which is more general than
    your request. I find it very useful.

    So do I! Just what I was looking for.

    Thanks,
    Johan


    --- Synchronet 3.21d-Linux NewsLink 1.2