Browse files

added doc

  • Loading branch information...
1 parent aa519f8 commit 54b023b8b87f6cb1ee7479ccd016452de2a88ae2 @sroccaserra committed Feb 24, 2010
Showing with 65 additions and 5 deletions.
  1. +31 −0
  2. +34 −5 smart-compile.el
@@ -0,0 +1,31 @@
+Small & useful Emacs functions.
+Smart Tab
+I like to have word completion near the homeline, and TAB feels natural to me.
+But I like to have automatic indentation bound to TAB as well. Fortunately,
+most of the time it is easy to decide which one I need. Smart Tab does that for
+Smart Compile
+I like to have a key bound to compile, and this key should do the right thing:
+if there is a Makefile in the current dir or upward, use `make`, else use
+`rake`. Or, if I\'m in an elisp file, just run elk tests. And saving the current
+buffer before doing anything avoids most `yes-or-no-p` questions.
+Flymake Lua
+Flymake for Lua...
+I use this to quickly create new posts, automatically using the current date.
39 smart-compile.el
@@ -1,6 +1,21 @@
(defvar *default-compilation-file* "Makefile")
(defun smart-compile ()
+ "Saves current buffer, and depending on context:
+- in an elisp file, runs elk tests and returns.
+- if the compile command contains \"make\", and a makefile is
+ found in the current directory or upward, runs the compile
+ command.
+- otherwise, switches to rake for the current buffer and
+ compiles.
+I use it like this:
+(global-set-key [(f9)] 'smart-compile)
(if eldoc-mode
@@ -24,11 +39,12 @@
(t (nearest-compilation-file parent compilation-file)))))
(defun reach-compilation-file ()
- "If your compile command containts 'make', goes up in the path until it finds a makefile.
+ "If your compile command containts 'make', goes up in the path
+until it finds a makefile. I use it like this:
-I use it like this:
- (add-hook 'compilation-mode-hook '(lambda ()
- (require 'reach-compilation-file)))"
+(eval-after-load \"compile\"
+ '(setq compilation-process-setup-function 'reach-compilation-file))
(when (string-match "make"
(car compilation-arguments))
(let ((compilation-file (nearest-compilation-file (expand-file-name default-directory)
@@ -37,6 +53,19 @@ I use it like this:
(error "No file named '%s' found" *default-compilation-file*))
(setq default-directory (file-name-directory compilation-file)))))
-(setq compilation-process-setup-function 'reach-compilation-file)
+(defun compile-goto-error-and-close-compilation-window ()
+ "Useful to close compilation windows, so you have only one
+window open at any time (I set `pop-up-windows' to nil). I use
+it like this:
+(eval-after-load \"compile\"
+ '(define-key
+ compilation-mode-map
+ [remap compile-goto-error]
+ 'compile-goto-error-and-close-compilation-window))
+ (interactive)
+ (compile-goto-error)
+ (delete-windows-on "*compilation*"))
(provide 'smart-compile)

0 comments on commit 54b023b

Please sign in to comment.