all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Scott Frazer <frazer.scott@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: emacs equivalent of vi %
Date: Wed, 13 Aug 2008 13:24:43 -0400	[thread overview]
Message-ID: <1218648284.122189@sj-nntpcache-3.cisco.com> (raw)
In-Reply-To: <mailman.16547.1218610362.18990.help-gnu-emacs@gnu.org>

Rustom Mody wrote:
> In vi one can do, for example,
> :!gcc %
> and the current file gets compiled -- ingeneral :
> :!someCommand options % otherStuff
> and the filename gets interpolated.
> Is there any way to get the '%' behavior in emacs?
> [Note: I know about compile; I am asking a more general question about
> getting the filename]
> 
> 

How about this:

(defun shell-command-on-current-file (command &optional output-buffer error-buffer)
   (interactive (list (read-from-minibuffer "Shell command: "
                                            nil nil nil 'shell-command-history)
                      current-prefix-arg
                      shell-command-default-error-buffer))
   (unless (buffer-file-name)
     (error "No file associated with this buffer"))
   (setq command (replace-regexp-in-string "%" (buffer-file-name) command nil t))
   (shell-command command output-buffer error-buffer))


Scott


  parent reply	other threads:[~2008-08-13 17:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.16547.1218610362.18990.help-gnu-emacs@gnu.org>
2008-08-13 15:14 ` emacs equivalent of vi % Xah
2008-08-13 17:24 ` Scott Frazer [this message]
     [not found] <mailman.16820.1218819789.18990.help-gnu-emacs@gnu.org>
2008-08-15 19:13 ` Xah
2008-08-16  0:14 ` Chat
2008-08-15 17:02 Emmett Grogan
  -- strict thread matches above, loose matches on Subject: below --
2008-08-13  6:52 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)
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

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=1218648284.122189@sj-nntpcache-3.cisco.com \
    --to=frazer.scott@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.