Skip to content

Commit

Permalink
added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sroccaserra committed Feb 24, 2010
1 parent aa519f8 commit 54b023b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 5 deletions.
31 changes: 31 additions & 0 deletions README.md
@@ -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
me.


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


Jekyll
------

I use this to quickly create new posts, automatically using the current date.
39 changes: 34 additions & 5 deletions smart-compile.el
@@ -1,6 +1,21 @@
(defvar *default-compilation-file* "Makefile") (defvar *default-compilation-file* "Makefile")


(defun smart-compile () (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)
"
(interactive) (interactive)
(save-buffer) (save-buffer)
(if eldoc-mode (if eldoc-mode
Expand All @@ -24,11 +39,12 @@
(t (nearest-compilation-file parent compilation-file))))) (t (nearest-compilation-file parent compilation-file)))))


(defun reach-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: (eval-after-load \"compile\"
(add-hook 'compilation-mode-hook '(lambda () '(setq compilation-process-setup-function 'reach-compilation-file))
(require 'reach-compilation-file)))" "
(when (string-match "make" (when (string-match "make"
(car compilation-arguments)) (car compilation-arguments))
(let ((compilation-file (nearest-compilation-file (expand-file-name default-directory) (let ((compilation-file (nearest-compilation-file (expand-file-name default-directory)
Expand All @@ -37,6 +53,19 @@ I use it like this:
(error "No file named '%s' found" *default-compilation-file*)) (error "No file named '%s' found" *default-compilation-file*))
(setq default-directory (file-name-directory 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) (provide 'smart-compile)

0 comments on commit 54b023b

Please sign in to comment.