First Attempt
I took, my first stab at my own emacs-lisp function. The purpose being
to make the *compilation* buffer disapear if there is no error. Initial
plans had a few more things I wanted, however they would have resulted
in a very inflexable function, which appears to be the very opposite of emacs.
My first attempt
(defun wramp-build (input) ;; how about filename
;;interactive?
if ((compile ./build.sh input)
(switch-to-buffer(remote))))
However a kind user bpalmer on #emacs pointed out that compile is an
asynchronous
process, which is a good thing, a different approach was neccesery. In
case anyones curious remote is program based on minicom used for serial
communication with computer designed and build at the Waikato University
for teaching assembly on, wramp is the name of said computer. The
following was supplied by bpalmer from the emacs-wiki
(setq compilation-finish-functions 'compile-autoclose) (defun compile-autoclose (buffer string) (cond ((string-match "finished" string) (bury-buffer "*compilation*") (winner-undo) (message "Build successful.")) (t (message "Compilation exited abnormally: %s" string))))
While I know I wouldnt have written that myself Im pretty sure I
understand what it does. All I know is I cant wait till exams finnish
as I will have time to start learning more emacs lisp.
[...] is kinda interesting where Ronnie Collinson removes the *compilation* buffer if the compile is successful. It isn’t something I personally would use as I like the [...]
I have an elisp function that kills the compilation window only if the compile is successful. I find it quite handy.
If its different to the one above, why dont you post it here as well for comparison
This is a combination of my compile window creation and destruction functions. What I like about this system is that the current window is split horizontally, the compile window appears, and the focus returns to the previous window. Finally, when the compile finishes, if there are no errors then the window is killed.
(setq compilation-scroll-output t)
(global-set-key [(f5)] ‘project-compile)
(setq compilation-window-height 24)
(setq compilation-finish-functions
‘((lambda (buf str)
(if (string-equal “*compilation*” (buffer-name buf))
(if (string-match “exited abnormally” str)
;;there were errors
(message “compilation errors, press C-x ` to visit”)
;;no errors, make the compilation window go away in 0.5 seconds
(run-at-time 0.5 nil ‘delete-windows-on buf)
(message “NO COMPILATION ERRORS!”))))))
(setq split-height-threshold 500)
(setq special-display-buffer-names
‘(“*compilation*” “*ack*”))
(setq special-display-function
(lambda (buffer &optional args)
(save-excursion
(save-selected-window
(split-window)
(switch-to-buffer buffer)
(enlarge-window (- compilation-window-height (window-height)))
(selected-window)))))
.
(setq compilation-scroll-output t) (global-set-key [(f5)] 'project-compile) (setq compilation-window-height 24) (setq compilation-finish-functions '((lambda (buf str) (if (string-equal "*compilation*" (buffer-name buf)) (if (string-match "exited abnormally" str) ;;there were errors (message "compilation errors, press C-x ` to visit") ;;no errors, make the compilation window go away in 0.5 seconds (run-at-time 0.5 nil 'delete-windows-on buf) (message "NO COMPILATION ERRORS!")))))) (setq split-height-threshold 500) (setq special-display-buffer-names '("*compilation*" "*ack*")) (setq special-display-function (lambda (buffer &optional args) (save-excursion (save-selected-window (split-window) (switch-to-buffer buffer) (enlarge-window (- compilation-window-height (window-height))) (selected-window)))))Now with twice as much monospace!