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

Drew
  • 75,699
  • 9
  • 109
  • 225

1 Answers1

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)))))
Drew
  • 75,699
  • 9
  • 109
  • 225
  • It works thanks, is there a way to skip the question: "A compilation process is running; Kill it? "(y or n)" – oleg harput Mar 18 '21 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 Mar 18 '21 at 23:16