Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Emacs variables to minibuffer shell commands

Tags:

emacs

emacs23

I can run a shell command quickly by hitting M-!. One thing I'd like to do is perform shell quick operations on the current file. An example would be checking the file out through perforce:

M-! p4 edit buffer-file-name RET

(Yes there are perforce integrations, but I'm more interested in the minishell/variable problem rather than a specific workflow)

Of course, the buffer-file-name variable is not evaluated before the command is sent to the shell.

Is there an easy on-the-fly way to do this? Or will I have to roll a custom elisp function?

like image 943
tenpn Avatar asked Apr 12 '12 10:04

tenpn


1 Answers

It seems current Emacs has something built-in to achieve the desired result, after M-! (shell-command) press <down>, you will get the file name you are currently visiting on the prompt. Now you can edit it to add the command you want to run on it.

In dired-mode it will give you the file your cursor is currently on.

like image 186
Arne Brasseur Avatar answered Oct 14 '22 16:10

Arne Brasseur