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.

About these ads

6 comments so far

  1. [...] 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 [...]

  2. Josh Matthews on

    I have an elisp function that kills the compilation window only if the compile is successful. I find it quite handy.

    • notthinking on

      If its different to the one above, why dont you post it here as well for comparison

    • Josh Matthews on

      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)))))

      • Josh Matthews on
        This reply is just testing to see if I can force a monospace font somehow

        .

      • Josh Matthews on
        (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!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: