2

i have

(defun insert-buffername ()
 (interactive)
 (compile (concat "lua " (buffer-file-name))))

 (global-set-key (kbd "C-c C-e") #'insert-buffername)

but when i use this key binding it always asks me "Save file: (y, n, !, ...)" question which i would prefer not to see every time. I can not adopt the code in https://www.emacswiki.org/emacs/YesOrNoP to my case. Need help

1 Answer 1

2

Try customizing (or binding) compilation-ask-about-save to nil. C-h v tells you:

compilation-ask-about-save is a variable defined in compile.el.

Its value is t

Documentation:

Non-nil means M-x compile asks which buffers to save before compiling.

Otherwise, it saves all modified buffers without asking.

You can customize this variable.

If you want to just bind it in your command, then do this:

(defun insert-buffername ()
  (interactive)
  (let ((compilation-ask-about-save  nil))
   (compile (concat "lua " (buffer-file-name)))))
2
  • It works thanks, is there a way to skip the question: "A compilation process is running; Kill it? "(y or n)" Commented Mar 18, 2021 at 22:06
  • For that it looks like you would have to bind function yes-or-no-p to a function that just returns t, around the call to compile. E.g. ((cl-flet ((yes-or-no-p (x) t)) ...))
    – Drew
    Commented Mar 18, 2021 at 23:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.