Passing Emacs variables to minibuffer shell commands

前端 未结 6 2100
误落风尘
误落风尘 2020-12-19 06:13

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 th

6条回答
  •  孤城傲影
    2020-12-19 06:50

    You can't do that with M-!, but you can evaluate arbitrary elisp from the minibuffer, so writing a function isn't strictly necessary:

    M-: (shell-command (format "p4 edit %s" (shell-quote-argument buffer-file-name))) RET

    In this case however, I think eshell is what you want to use:

    M-x eshell-command RET p4 edit (eval buffer-file-name) RET

    Edit: Except unfortunately that doesn't work, as the *eshell cmd* buffer is selected when that is evaluated. One solution would be:

    M-x eshell-command RET p4 edit (eval buffer-file-name (other-buffer nil t)) RET

    (Not quite as elegant, sorry.)

提交回复
热议问题