Formats cmake file only if a project-wide configuration file is found

Otherwise do nothing.
This commit is contained in:
2024-12-18 10:31:23 +01:00
parent 4f4d5a4109
commit d9d4ff91e3

10
.emacs
View File

@@ -473,8 +473,14 @@
(defun atu/cmake-format-buffer () (defun atu/cmake-format-buffer ()
"Formats the current buffer using cmake-format" "Formats the current buffer using cmake-format"
(interactive) (interactive)
(let ((error-buffer (atu/create-or-erase-buffer "*cmake-format:stderr*"))) (let (
(error-buffer (atu/create-or-erase-buffer "*cmake-format:stderr*"))
(cmake-format-config-file-exists
(file-exists-p (projectile-expand-root ".cmake-format.yaml"))
)
)
(setq-local atu/after-save-message nil) (setq-local atu/after-save-message nil)
(if cmake-format-config-file-exists
(if (eq 0 (call-process-region (if (eq 0 (call-process-region
;;region ;;region
(point-min) (point-min)
@@ -501,6 +507,8 @@
(buffer-name) error-buffer) (buffer-name) error-buffer)
(current-message) (current-message)
) )
(message "cmake-format: skipping as no configuration file found")
)
) )
) )