0

I just migrated from vim to emacs and I'm editing an HTML file now.

In vim, I can use !firefox % to open current file.

But in emacs, if I typed M-! then firefox %f, it uses firefox to open

http://www.%f.com/

page.

I tried firefox (buffer-name), it doesn't work for me as well.

Could anyone tell me the expression which stands for the current file?

I found some similar questions, but the solutions are all about writing lisp function then use key bindings. I wish I could just use some kind of placeholder like %f within the shell command, and have it automatically expand to the buffer's filename when Emacs runs the command.

phils
  • 71,335
  • 11
  • 153
  • 198
bearer1024
  • 159
  • 1
  • 1
  • 8
  • I believe I understand what you want to do, but I'm very confused about your references to "regex" in both the text and the tags. I can't see any use of regular expressions anywhere in this question. – phils Mar 06 '17 at 00:03
  • If you have searched similar questions, you should link to them so that we can see what you've already looked at. – phils Mar 06 '17 at 00:07
  • @philsThank you for your suggestions. I searched similar questions, I think it belongs to regex because I want to use "*,%,%s" these symbols to represent current filename. – bearer1024 Mar 06 '17 at 14:30
  • @phils,I found a solution according to the similar question link. After M-!, I can use key to get current filename. – bearer1024 Mar 06 '17 at 14:34
  • Yes, that's a good way to do it. FYI regular expressions are for *matching patterns* in text, whereas you're describing using special place-holder tokens which automatically *expand* into particular values. They're two entirely different concepts. I shall edit the regex term out of the question... – phils Mar 06 '17 at 22:00

0 Answers0