reddit / emacs

Trying to define a keybinding to compile and run c++ code on vterm but getting error usr/bin/time: no such file or directory

tanishk56bisht · 2022-06-17 08:18
I copied this code from codechef: But when i press F9 vterm buffer gets activated and the error saying Usr/bin/time: no such file or directory Pops up Help please (defun er-switch-to-previous-buffer () "Switch to previously open buffer. Repeated invocations toggle between the two most recently open buffers." (interactive) (switch-to-buffer-other-frame (other-buffer (current-buffer) 1))) (defun runc() "Build and runc .cpp files" (interactive) (if (or (string= major-mode "c++-mode") (boundp 'file)) (let ((a 10)) (if (string= major-mode "c++-mode") (setq file (buffer-file-name (window-buffer (minibuffer-selected-window))))) (evil-write-all nil) (setq code-buf-default-directory default-directory) (if (boundp 'buf) (pop-to-buffer buf) (setq buf (+vterm/toggle nil))) (vterm-send-string (concat "cd " code-buf-default-directory "; ") ) (vterm-send-string (concat "g++ '" file "' -o ~/dDg && echo 'Compiled.'; /usr/bin/time -f \"Executed in %esec. Used %KKB.\" ~/dDg; rm ~/dDg;") ) (vterm-send-return) (with-current-buffer buf (evil-normal-state)) (er-switch-to-previous-buffer)))) (map! :desc "Run c++ code" "<f9>" #'runc)
flexibeast · 2022-06-17 08:52
Well, is the `time` executable available in `/usr/bin/` on your system?
tanishk56bisht · 2022-06-17 10:33
No When i do Which usr/bin/time on terminal It says not found
flexibeast · 2022-06-17 10:57
Okay, so assuming the executable isn't available at another location, you either need to install it, or change the ELisp to not call `/usr/bin/time`.
tanishk56bisht · 2022-06-17 11:03
Yeah I fixed it by reinstalling the time sudo apt-get install --reinstall time And now i run whereis time it clearly shows /usr/bin/time Thanks But there is another problem now when i run the code the vterm shows up the previous error doesn't show up but a message pops up saying cmdand quote> and nothing is shown after this Help me with this plz
flexibeast · 2022-06-17 11:09
That means there are unbalanced quotes somewhere in the command string(s) being passed to vterm.
Salty_Influence_5113 · 2022-06-17 13:27
Maybe project-compile will be better solution?
tanishk56bisht · 2022-06-17 13:42
Yesss I found that Now everything is running fine Thanks
tanishk56bisht · 2022-06-17 13:43
Is that a package?
Salty_Influence_5113 · 2022-06-17 13:57
In larest versions of emacs- built in