From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Rustom Mody" Newsgroups: gmane.emacs.help Subject: Re: emacs equivalent of vi % Date: Thu, 14 Aug 2008 12:43:28 +0530 Message-ID: References: <48A2AABF.9010402@gmail.com> <48A2C12B.5090309@gmail.com> <48A378F8.4050908@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1218698063 29029 80.91.229.12 (14 Aug 2008 07:14:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Aug 2008 07:14:23 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Lennart Borgman (gmail)" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 14 09:15:15 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KTX2o-0002gk-Mc for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Aug 2008 09:14:50 +0200 Original-Received: from localhost ([127.0.0.1]:46459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTX1s-0000Uj-3g for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Aug 2008 03:13:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KTX1Z-0000UR-9V for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 03:13:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KTX1X-0000UE-Qd for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 03:13:32 -0400 Original-Received: from [199.232.76.173] (port=51662 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTX1X-0000UB-Li for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 03:13:31 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:23413) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KTX1X-0004XO-5i for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 03:13:31 -0400 Original-Received: from yx-out-1718.google.com ([74.125.44.154]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KTX1V-0006Qv-Uy for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 03:13:30 -0400 Original-Received: by yx-out-1718.google.com with SMTP id 34so215243yxf.66 for ; Thu, 14 Aug 2008 00:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=qfO3k6jgYUTNzkiv43bMxDTJ2DU8Fyw0jDjCwjL/ziw=; b=Ek5IdFuu4yENqUseA9axdGc9QEDVHrV9u2fiA7jQdDCTGmta4piBrevEr6USm0OZWK W/8dP8SFK1ohxFFypNZJeZXNUVtZB5w8ga/iCPMKfXiBqskzce4zsN5WCZ44EdEOXRf3 kfdY32M0DO7zCT+LT8cLRcOSroJg56wwrXVFI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=oGdEymqc27InNzxI31woVmn1FHzL64pRMAwbAo3x6V3c/UW6MtrmBrrSjSIEcgXUcQ yxaOFp8PeZDWUGIyMdD3CH1wxRfFvuLKUGTwaqGy6VxvNBYmn3zyxMjck+jr/UfW8sdy qqqxFuuzZmGOoxBKJ3kAdkpkCixnr8OAXGi5s= Original-Received: by 10.142.214.5 with SMTP id m5mr349810wfg.257.1218698008253; Thu, 14 Aug 2008 00:13:28 -0700 (PDT) Original-Received: by 10.142.156.11 with HTTP; Thu, 14 Aug 2008 00:13:28 -0700 (PDT) In-Reply-To: <48A378F8.4050908@gmail.com> Content-Disposition: inline X-detected-kernel: by mx20.gnu.org: Linux 2.6 (newer, 2) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56592 Archived-At: Thanks folks! Heres the code I have: (define-key minibuffer-local-map "%" 'percentsub) (defun percentsub () (interactive) (insert (file-name-nondirectory (buffer-file-name (window-buffer (minibuffer-selected-window)))))) Prior to Lennarts suggestion I had hacked together (cadr (buffer-list)) in place of the last line which was of course quite unacceptable Any further suggested improvements? I guess this is going to fail in some cases when theres no filename... On Thu, Aug 14, 2008 at 5:44 AM, Lennart Borgman (gmail) wrote: > Nikolaj Schumacher wrote: >> >> Nikolaj Schumacher wrote: >> >>> "Rustom Mody" wrote: >>> >>>> Bind the character '%' to >>>> (file-name-nondirectory (buffer-file-name)) >>> >>> Also, note that you'll need to make an interactive function out of the >>> form to bind it to a key. >> >> Oups, that's not all... >> It won't work, because `buffer-file-name' will of course return the >> minibuffer's file name (i.e. none). I'm currently not aware of an easy >> way to get the originating buffer from the minibuffer. Sorry. > > > Maybe minibuffer-selected-window + window-buffer? >