unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* insert-file-name-into-minibuffer
@ 2019-02-09 14:39 Alexander Klimov
  2019-02-09 14:50 ` insert-file-name-into-minibuffer Eli Zaretskii
  2019-02-17  7:09 ` insert-file-name-into-minibuffer Marcin Borkowski
  0 siblings, 2 replies; 9+ messages in thread
From: Alexander Klimov @ 2019-02-09 14:39 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-17  7:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-09 14:39 insert-file-name-into-minibuffer Alexander Klimov
2019-02-09 14:50 ` insert-file-name-into-minibuffer Eli Zaretskii
2019-02-09 21:30   ` insert-file-name-into-minibuffer Alexander Klimov
2019-02-09 21:38     ` insert-file-name-into-minibuffer Marcin Borkowski
2019-02-09 21:50       ` insert-file-name-into-minibuffer Alexander Klimov
2019-02-09 21:59         ` insert-file-name-into-minibuffer Marcin Borkowski
2019-02-09 22:19           ` insert-file-name-into-minibuffer Alexander Klimov
2019-02-13 18:49             ` insert-file-name-into-minibuffer Marcin Borkowski
2019-02-17  7:09 ` insert-file-name-into-minibuffer Marcin Borkowski

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).