all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: emacs equivalent of vi %
Date: Wed, 13 Aug 2008 20:04:33 -0600	[thread overview]
Message-ID: <g803rc$m1k$1@ger.gmane.org> (raw)
In-Reply-To: <48A378F8.4050908@gmail.com>

Lennart Borgman (gmail) 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?

Brilliant!

(defvar minibuffer-insert-buffer-directory nil)

(defun minibuffer-insert-buffer-file-name ()
   (interactive)
   (unless (minibuffer-window-active-p (selected-window))
     (error "Minibuffer window is not active"))
   (let ((minibuffer-selected-buffer-file-name
	 (buffer-file-name (window-buffer (minibuffer-selected-window)))))
     (insert (if minibuffer-insert-buffer-directory
		minibuffer-selected-buffer-file-name
	      (file-name-nondirectory minibuffer-selected-buffer-file-name)))))

(define-key minibuffer-local-map "%" 'minibuffer-insert-buffer-file-name)
(define-key minibuffer-local-completion-map "%" nil)

-- 
Kevin Rodgers
Denver, Colorado, USA





  reply	other threads:[~2008-08-14  2:04 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 [this message]
2008-08-14  7:13               ` Rustom Mody
2008-08-14 10:01                 ` Lennart Borgman (gmail)
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='g803rc$m1k$1@ger.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.