emacsorphanage / dart-mode

An Emacs mode for the Dart language
GNU General Public License v3.0
15 stars 2 forks source link

Windows, no such file or directory, diff #73

Closed bradyt closed 5 years ago

bradyt commented 5 years ago

In Windows, with (setq debug-on-error t), when I call dart-format with C-c C-o, I get the following backtrace.

Debugger entered--Lisp error: (file-missing "Searching for program" "No such file or directory" "diff")
  call-process-region(1 2296 "diff" "c:/Users/ADMINI~1/AppData/Local/Temp/2/emwTyUAE" #<buffer *Dart formatter patch*> nil "--rcs" "-" "c:/Users/ADMINI~1/AppData/Local/Temp/2/formatUIeOOO.dart")
  (= 0 (call-process-region (point-min) (point-max) "diff" nil patch-buffer nil "--rcs" "-" file))
  (if (= 0 (call-process-region (point-min) (point-max) "diff" nil patch-buffer nil "--rcs" "-" file)) (message "Buffer is already formatted") (dart--apply-rcs-patch patch-buffer) (message "Formatted buffer"))
  (save-restriction (widen) (if error-buffer (progn (save-current-buffer (set-buffer error-buffer) (setq buffer-read-only nil) (erase-buffer)))) (write-region nil nil file nil 'no-message) (dart-info (format "%s %s" (dart-formatter-command) args)) (if (= 0 (apply (function call-process) (dart-formatter-command) nil error-buffer nil args)) nil (message "Formatting failed") (if error-buffer (progn (dart--formatter-show-errors error-buffer file (buffer-file-name)))) (throw '--cl-block-dart-format-- nil)) (if (= 0 (call-process-region (point-min) (point-max) "diff" nil patch-buffer nil "--rcs" "-" file)) (message "Buffer is already formatted") (dart--apply-rcs-patch patch-buffer) (message "Formatted buffer")) (if error-buffer (progn (dart--kill-buffer-and-window error-buffer))))
  (unwind-protect (save-restriction (widen) (if error-buffer (progn (save-current-buffer (set-buffer error-buffer) (setq buffer-read-only nil) (erase-buffer)))) (write-region nil nil file nil 'no-message) (dart-info (format "%s %s" (dart-formatter-command) args)) (if (= 0 (apply (function call-process) (dart-formatter-command) nil error-buffer nil args)) nil (message "Formatting failed") (if error-buffer (progn (dart--formatter-show-errors error-buffer file (buffer-file-name)))) (throw '--cl-block-dart-format-- nil)) (if (= 0 (call-process-region (point-min) (point-max) "diff" nil patch-buffer nil "--rcs" "-" file)) (message "Buffer is already formatted") (dart--apply-rcs-patch patch-buffer) (message "Formatted buffer")) (if error-buffer (progn (dart--kill-buffer-and-window error-buffer)))) (kill-buffer patch-buffer) (delete-file file))
  (let* ((file (make-temp-file "format" nil ".dart")) (patch-buffer (get-buffer-create "*Dart formatter patch*")) (error-buffer (if dart-formatter-show-errors (progn (get-buffer-create "*Dart formatter errors*")))) (coding-system-for-read 'utf-8) (coding-system-for-write 'utf-8) (args (list "--line-length" (number-to-string dart-formatter-line-length) "--overwrite" file))) (unwind-protect (save-restriction (widen) (if error-buffer (progn (save-current-buffer (set-buffer error-buffer) (setq buffer-read-only nil) (erase-buffer)))) (write-region nil nil file nil 'no-message) (dart-info (format "%s %s" (dart-formatter-command) args)) (if (= 0 (apply (function call-process) (dart-formatter-command) nil error-buffer nil args)) nil (message "Formatting failed") (if error-buffer (progn (dart--formatter-show-errors error-buffer file (buffer-file-name)))) (throw '--cl-block-dart-format-- nil)) (if (= 0 (call-process-region (point-min) (point-max) "diff" nil patch-buffer nil "--rcs" "-" file)) (message "Buffer is already formatted") (dart--apply-rcs-patch patch-buffer) (message "Formatted buffer")) (if error-buffer (progn (dart--kill-buffer-and-window error-buffer)))) (kill-buffer patch-buffer) (delete-file file)))
  (catch '--cl-block-dart-format-- (let* ((file (make-temp-file "format" nil ".dart")) (patch-buffer (get-buffer-create "*Dart formatter patch*")) (error-buffer (if dart-formatter-show-errors (progn (get-buffer-create "*Dart formatter errors*")))) (coding-system-for-read 'utf-8) (coding-system-for-write 'utf-8) (args (list "--line-length" (number-to-string dart-formatter-line-length) "--overwrite" file))) (unwind-protect (save-restriction (widen) (if error-buffer (progn (save-current-buffer (set-buffer error-buffer) (setq buffer-read-only nil) (erase-buffer)))) (write-region nil nil file nil 'no-message) (dart-info (format "%s %s" (dart-formatter-command) args)) (if (= 0 (apply (function call-process) (dart-formatter-command) nil error-buffer nil args)) nil (message "Formatting failed") (if error-buffer (progn (dart--formatter-show-errors error-buffer file (buffer-file-name)))) (throw '--cl-block-dart-format-- nil)) (if (= 0 (call-process-region (point-min) (point-max) "diff" nil patch-buffer nil "--rcs" "-" file)) (message "Buffer is already formatted") (dart--apply-rcs-patch patch-buffer) (message "Formatted buffer")) (if error-buffer (progn (dart--kill-buffer-and-window error-buffer)))) (kill-buffer patch-buffer) (delete-file file))))
  dart-format()
  funcall-interactively(dart-format)
  call-interactively(dart-format nil nil)
  command-execute(dart-format)
bradyt commented 5 years ago

Presumably fixed in https://github.com/bradyt/dart-mode/commit/1879cb8ce579889fe3d993f3b728fe381482fd2a.

That is, by installing diff on Windows, and making sure it is on PATH for OS and/or Emacs.