In vim, it's pretty common to run commands like
:!gcc %
It's pretty simple and the syntax is really easy to remember, ":" for command mode, "!" to run something, and in the command "%" will be replaced by your filename.
I haven't found anything similar to "%" for emacs, so let's write some elisp to fix it.
(defun shell-execute () (interactive) (let ((file-buffer (or (buffer-file-name) "")) (command (read-shell-command "Shell command: " nil nil nil))) (shell-command (replace-regexp-in-string "%" file-buffer command)))) (global-set-key (kbd "M-!") 'shell-execute)
2 comentarios:
I use '!' on dired (it is provided by dired-aux). You can execute a command the marked files.
See also http://stackoverflow.com/questions/10121944/passing-emacs-variables-to-minibuffer-shell-commands
Publicar un comentario