[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacs equivalent of vi %
From: |
Rustom Mody |
Subject: |
Re: emacs equivalent of vi % |
Date: |
Thu, 14 Aug 2008 12:43:28 +0530 |
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)
<lennart.borgman@gmail.com> wrote:
> Nikolaj Schumacher wrote:
>>
>> Nikolaj Schumacher <n_schumacher@web.de> wrote:
>>
>>> "Rustom Mody" <rustompmody@gmail.com> 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?
>
- emacs equivalent of vi %, Rustom Mody, 2008/08/13
- Re: emacs equivalent of vi %, Lennart Borgman (gmail), 2008/08/13
- Re: emacs equivalent of vi %, Rustom Mody, 2008/08/13
- Re: emacs equivalent of vi %, Lennart Borgman (gmail), 2008/08/13
- Re: emacs equivalent of vi %, Rustom Mody, 2008/08/13
- Re: emacs equivalent of vi %, Nikolaj Schumacher, 2008/08/13
- Re: emacs equivalent of vi %, Nikolaj Schumacher, 2008/08/13
- Re: emacs equivalent of vi %, Lennart Borgman (gmail), 2008/08/13
- Re: emacs equivalent of vi %, Kevin Rodgers, 2008/08/13
- Re: emacs equivalent of vi %,
Rustom Mody <=
- Re: emacs equivalent of vi %, Lennart Borgman (gmail), 2008/08/14
- Re: emacs equivalent of vi %, Kevin Rodgers, 2008/08/14
- Message not available
- Re: emacs equivalent of vi %, Jason Rumney, 2008/08/13
RE: emacs equivalent of vi %, Arnaldo Mandel, 2008/08/13
- Re: emacs equivalent of vi %, Xah, 2008/08/13
- Re: emacs equivalent of vi %, Scott Frazer, 2008/08/13
- Re: emacs equivalent of vi %, Emmett Grogan, 2008/08/15
- Re: emacs equivalent of vi %, Xah, 2008/08/15
- Re: emacs equivalent of vi %, Chat, 2008/08/16