0

I have this function implemented to basically compile and run the cpp file I am writing. Some files needs input (cin) so running this function will not stop and would continuously showing this message:

emacs Enter a positive, odd integer (-1 to exit program): Only digits are allowed!

Not sure what is wrong:

  (defun run-it ()
    "Run it on the current file."
    (interactive)
    (save-all-buffer)
    (let ((file-name (file-name-nondirectory buffer-file-name)))
    (shell-command
     (format
        (concat "g++ -std=c++11 " file-name " -o " file-name ".o; "
                 "./" file-name ".o;")))
         ))
3
  • Although perhaps not the source of your problem, format does not do anything here, so maybe just remove it along with the opening/closing parentheses.
    – lawlist
    Dec 24, 2019 at 0:19
  • Surely not the problem, but you call the compiled executable file.o?
    – JeanPierre
    Dec 25, 2019 at 7:45
  • Probably (save-all-buffer) this is no official function. The rest works.
    – jue
    Dec 25, 2019 at 22:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.