help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing current buffer to compile command


From: duke
Subject: Re: Passing current buffer to compile command
Date: Mon, 17 Jan 2011 21:14:09 -0800 (PST)
User-agent: G2/1.0

On Jan 17, 8:42 pm, rusi <rustompm...@gmail.com> wrote:
> On Jan 18, 12:07 am, duke <sidney.reilley...@gmail.com> wrote:
>
>
>
> > On Jan 16, 8:49 pm, rusi <rustompm...@gmail.com> wrote:
>
> > > On Jan 17, 8:29 am, rusi <rustompm...@gmail.com> wrote:
>
> > > > The following will give that to you in the minibuffer
> > > > [But beware of using it with buffers that have no file associated)
>
> > > Now "No-file" should not misbehave
>
> > > (savehist-mode 1)
> > > (define-key minibuffer-local-map "%"
> > >   (function
> > >    (lambda ()
> > >      (interactive)
> > >      (let ((file-path-maybe (buffer-file-name
> > >                              (window-buffer 
> > > (minibuffer-selected-window)))))
> > >      (insert (if file-path-maybe
> > >                  (file-name-nondirectory file-path-maybe)
> > >                "%"))))))
>
> > You are too kind! Much obliged for the snippet, but especially the
> > courtesy. Can't wait to hack my .emacs and try it out :)
>
> I should attribute this to someone (who helped me write this) -- but
> cant remember who :-)
>
> More emacs-ish than vi-ish is to change the first line to
> (define-key minibuffer-local-map (kbd "C-f")
> ;; analogous to C-x C-f
>
> But then the last "%" is of course wrong and I dont know what to do
> with it.
> There should be a way of chaining back to the default binding of C-f
> But (lookup-key minibuffer-local-map (kbd "C-f")) is giving nil --- So
> dunno...

Don't worry about it. The snippet works great "as is". I'll bet that
the  "gurus"
have scooped this one up.  :) Thanks again.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]