Initial import

This commit is contained in:
Michael Wolf
2020-05-22 10:44:52 -05:00
commit cf3493c9c5
4 changed files with 183 additions and 0 deletions

70
_dir-locals.el Normal file
View File

@@ -0,0 +1,70 @@
((nil . ((eval .
(progn (add-hook
'after-save-hook
(lambda ()
(let* ((file-name (buffer-file-name))
(would-reformat-cmd
(format "%s/bin/would-reformat.sh %s"
(projectile-project-root)
file-name))
(res (shell-command-to-string would-reformat-cmd)))
(progn (message (format "doing %s" file-name))
(message (format "running command: %s" would-reformat-cmd))
(cond ((string-equal res "would change")
(message (format "file `%s' would change (%s)" file-name res)))
((string-equal res "would not change")
(message (format "file `%s' would not change (%s)" file-name res)))
;; ((string-equal "ignoring") t)
))))
nil
t)
(global-set-key
[f1]
(lambda ()
(interactive)
(if (buffer-modified-p)
(message "save buffer first")
(let* ((file-name (buffer-file-name))
;; tx https://stackoverflow.com/a/23299809
(do-reformat-cmd
(format "%s/bin/do-reformat.sh" (projectile-project-root)))
(result (funcall
(lambda (program &rest args)
"Run PROGRAM with ARGS and return the exit code and output in a list."
;; (interactive)
(with-temp-buffer
(list (apply 'call-process program nil (current-buffer) nil args)
(buffer-string))))
do-reformat-cmd
file-name))
(status (car result))
(output (car (cdr result))))
(cond ((= status 0)
(progn (revert-buffer nil t)
(message (format "%s" output))))
((/= status 0)
(message (format "%s" output)))))))
)
(global-set-key
[(shift f1)]
(lambda ()
(interactive)
(let* ((file-name (buffer-file-name))
(would-reformat-cmd
(format "%s/bin/would-reformat.sh %s"
(projectile-project-root)
file-name))
(res (shell-command-to-string would-reformat-cmd)))
(progn (message (format "doing %s" file-name))
(message (format "running command: %s" would-reformat-cmd))
(cond ((string-equal res "would change")
(message (format "file `%s' would change (%s)" file-name res)))
((string-equal res "would not change")
(message (format "file `%s' would not change (%s)" file-name res)))
((string-equal res "syntax error")
(message (format "file `%s' has a syntax error (%s)" file-name res)))
;; ((string-equal "ignoring") t)
)))))
)))))