From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.devel Subject: Re: insert-file-name-into-minibuffer Date: Sun, 17 Feb 2019 08:09:40 +0100 Message-ID: <87tvh2q4az.fsf@mbork.pl> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="264799"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: emacs-devel@gnu.org To: Alexander Klimov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 17 08:10:48 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvGbA-0016lg-Bz for ged-emacs-devel@m.gmane.org; Sun, 17 Feb 2019 08:10:48 +0100 Original-Received: from localhost ([127.0.0.1]:37515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvGb9-0000oD-3N for ged-emacs-devel@m.gmane.org; Sun, 17 Feb 2019 02:10:47 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvGb3-0000o4-45 for emacs-devel@gnu.org; Sun, 17 Feb 2019 02:10:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvGb2-00080l-3d for emacs-devel@gnu.org; Sun, 17 Feb 2019 02:10:41 -0500 Original-Received: from mail.mojserwer.eu ([195.110.48.8]:56204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvGb1-0007zy-S9 for emacs-devel@gnu.org; Sun, 17 Feb 2019 02:10:40 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 35020E68C5; Sun, 17 Feb 2019 08:10:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0RZXgdtRVA6d; Sun, 17 Feb 2019 08:10:30 +0100 (CET) Original-Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 07857E66A3; Sun, 17 Feb 2019 08:10:29 +0100 (CET) In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.110.48.8 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233424 Archived-At: On 2019-02-09, at 15:39, Alexander Klimov wrote: > 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) Hi, it seems I reinvented your code and written about it on my blog: http://mbork.pl/2019-02-17_Inserting_the_current_file_name_at_point (don't worry, you get the credit). Thanks again! Best, -- Marcin Borkowski http://mbork.pl