all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: Rustom Mody <rustompmody@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: emacs equivalent of vi %
Date: Thu, 14 Aug 2008 12:01:42 +0200	[thread overview]
Message-ID: <48A40286.4090801@gmail.com> (raw)
In-Reply-To: <f46c52560808140013j379257edm3fd6bdac8f857a9b@mail.gmail.com>

Rustom Mody wrote:
> 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...

If you want to add it just to the ":" prompt:

(eval-after-load 'viper-keym
   '(define-key viper-ex-cmd-map [?%] 'percentsub))

> 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?
>>
> 




  reply	other threads:[~2008-08-14 10:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13  6:52 emacs equivalent of vi % Rustom Mody
2008-08-13  9:34 ` Lennart Borgman (gmail)
2008-08-13 10:44   ` Rustom Mody
2008-08-13 11:10     ` Lennart Borgman (gmail)
2008-08-13 13:24       ` Rustom Mody
2008-08-13 23:27         ` Nikolaj Schumacher
2008-08-13 23:50           ` Nikolaj Schumacher
2008-08-14  0:14             ` Lennart Borgman (gmail)
2008-08-14  2:04               ` Kevin Rodgers
2008-08-14  7:13               ` Rustom Mody
2008-08-14 10:01                 ` Lennart Borgman (gmail) [this message]
2008-08-15  1:38                 ` Kevin Rodgers
     [not found]           ` <mailman.16634.1218671422.18990.help-gnu-emacs@gnu.org>
2008-08-14  2:51             ` Jason Rumney
2008-08-13 11:37 ` Arnaldo Mandel
     [not found] <mailman.16547.1218610362.18990.help-gnu-emacs@gnu.org>
2008-08-13 15:14 ` Xah
2008-08-13 17:24 ` Scott Frazer
  -- strict thread matches above, loose matches on Subject: below --
2008-08-15 17:02 Emmett Grogan
     [not found] <mailman.16820.1218819789.18990.help-gnu-emacs@gnu.org>
2008-08-15 19:13 ` Xah
2008-08-16  0:14 ` Chat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48A40286.4090801@gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=rustompmody@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.