emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

insert-file-name-into-minibuffer


From: Alexander Klimov
Subject: insert-file-name-into-minibuffer
Date: Sat, 9 Feb 2019 14:39:36 +0000

It is quite common to insert the name of the current file into the 
argument of shell-command or compile command (both use 
read-shell-command). I wonder what it the preferred way to do it?

I currently use the following to allow M-. or C-u M-. to be used to
insert the file name or its full path:

(defun insert-file-name-into-minibuffer (full-path)
  (interactive "P")
  (let ((path (buffer-file-name (window-buffer (minibuffer-selected-window)))))
    (insert (if full-path
                path
              (file-name-nondirectory path)))))
(define-key minibuffer-local-map (kbd "M-.") 'insert-file-name-into-minibuffer)

-- 
Regards,
ASK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]