Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:05:32+00:00 2026-06-01T23:05:32+00:00

I can run a shell command quickly by hitting M-! . One thing I’d

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:05:33+00:00Added an answer on June 1, 2026 at 11:05 pm

    Indeed using C-u M-: is almost right. I’m not so sure about using shell-quote-argument in eval-to-shell-argument since it only works on strings making it impossible to use eval-to-shell-argument to insert a number or a symbol. You could try something like:

    (defun sm-minibuffer-insert-val (exp)
      (interactive
       (list (let ((enable-recursive-minibuffers t))
               (read-from-minibuffer "Insert: "
                                     nil read-expression-map t
                                     'read-expression-history))))
        (let ((val (with-selected-window (minibuffer-selected-window)
                     (eval exp)))
              (standard-output (current-buffer)))
          (prin1 val)))
    

    and then bind this function in your minibuffer with (define-key minibuffer-local-map [?\M-:] 'sm-minibuffer-insert-val).
    Of course, if the only thing you ever want to insert is the buffer-file-name, then your execute-shell-command-on-buffer is simpler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like a command line function that I can run on any file
how can I provide feedback for a shell command that may run for quite
In VIM one can run a Bash command with :!<command> . How can one
I have a shell script that I can run successfully from the command line.
When i use dired mode in emacs, I can run a shell command by
I have a single windows shell command I'd like to run (via EXEC master..xp_cmdshell)
How can i run a shell command in objective c with a variable E.G
How can I run a shell script in Mac Os X at a certain
I know that cd is a shell built-in ,and I can run it by
I can run this command in SqlManager to detach the db ALTER DATABASE mydb

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.