Add configuration for travis-ci.

This commit is contained in:
Nikolaj Schumacher 2013-09-02 18:30:45 +02:00
commit 7b8b46fd8a
5 changed files with 96 additions and 38 deletions

40
.travis.yml Normal file
View file

@ -0,0 +1,40 @@
# https://github.com/rolandwalker/emacs-travis
language: emacs-lisp
env:
matrix:
- EMACS=emacs23
- EMACS=emacs24
- EMACS=emacs-snapshot
matrix:
allow_failures:
- env:
- EMACS=emacs-snapshot
install:
- if [ "$EMACS" = "emacs23" ]; then
sudo apt-get update -qq &&
sudo apt-get install -qq emacs23-gtk emacs23-el &&
mkdir -p lib && curl https://raw.github.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert.el > lib/ert.el;
fi
- if [ "$EMACS" = "emacs24" ]; then
sudo add-apt-repository -y ppa:cassou/emacs &&
sudo apt-get update -qq &&
sudo apt-get install -qq emacs24 emacs24-el;
fi
- if [ "$EMACS" = "emacs-snapshot" ]; then
sudo add-apt-repository -y ppa:cassou/emacs &&
sudo apt-get update -qq &&
sudo apt-get install -qq emacs-snapshot &&
sudo apt-get install -qq emacs-snapshot-el emacs-snapshot-gtk;
fi
- mkdir -p lib && curl https://raw.github.com/nschum/elisp-lint/stable/elisp-lint.el > lib/elisp-lint.el
script:
$EMACS --version && find *.el -not -name "tests.el" | xargs $EMACS -Q --batch -l lib/elisp-lint.el -f elisp-lint-files-batch
&& $EMACS -Q --batch -L lib -L . -l ert -l tests.el -f ert-run-tests-batch-and-exit
notifications:
email: false

16
README.md Normal file
View file

@ -0,0 +1,16 @@
window-numbering
================
Numbered window shortcuts for Emacs
[![Build Status](https://travis-ci.org/nschum/window-numbering.el.png?branch=master)](https://travis-ci.org/nschum/window-numbering.el)
Enable `window-numbering-mode` and use M-1 through M-0 to navigate.
If you want to affect the numbers, use window-numbering-before-hook or
window-numbering-assign-func.
For instance, to always assign the calculator window the number 9, add the
following to your .emacs:
(setq window-numbering-assign-func
(lambda () (when (equal (buffer-name) "*Calculator*") 9)))

37
tests.el Normal file
View file

@ -0,0 +1,37 @@
(require 'ert)
(require 'window-numbering)
(ert-deftest window-numbering-assign ()
(let ((window-numbering-windows (make-vector 10 nil))
(window-numbering-numbers (make-hash-table :size 10))
(window-numbering-left '(1 2 3)))
(should (not (null (window-numbering-assign 'xx 7))))
(should (null (window-numbering-assign 'yy 7)))
(should (not (null (window-numbering-assign 'zz 8))))
(should (equal 8 (gethash 'zz window-numbering-numbers)))
(should (equal 7 (gethash 'xx window-numbering-numbers)))
(should (equal 'zz (aref window-numbering-windows 8)))
(should (equal 'xx (aref window-numbering-windows 7)))
))
(ert-deftest window-numbering-assign-auto ()
(let ((window-numbering-windows (make-vector 10 nil))
(window-numbering-numbers (make-hash-table :size 10))
(window-numbering-left '(1 2 3 4)))
(should (eq 1 (window-numbering-assign 'xx)))
(should (not (null (window-numbering-assign 'yy 3))))
(should (eq 2 (window-numbering-assign 'zz)))
(should (eq 4 (window-numbering-assign 'aa)))
))
(ert-deftest window-numbering-calculate-left ()
(should (equal '(6) (window-numbering-calculate-left
[t t t t t nil t t t t])))
(should (equal '(1 2 3) (window-numbering-calculate-left
[nil nil nil t t t t t t t])))
(should (equal '(1 2 3 4 5 6 7 8 9 0)
(window-numbering-calculate-left
[nil nil nil nil nil nil nil nil nil nil])))
)

View file

@ -1,35 +0,0 @@
(require 'elk-test)
(deftest "window-numbering-assign"
(let ((window-numbering-windows (make-vector 10 nil))
(window-numbering-numbers (make-hash-table :size 10))
(window-numbering-left '(1 2 3)))
(assert-nonnil (window-numbering-assign 'xx 7))
(assert-nil (window-numbering-assign 'yy 7))
(assert-nonnil (window-numbering-assign 'zz 8))
(assert-equal 8 (gethash 'zz window-numbering-numbers))
(assert-equal 7 (gethash 'xx window-numbering-numbers))
(assert-equal 'zz (aref window-numbering-windows 8))
(assert-equal 'xx (aref window-numbering-windows 7))
))
(deftest "window-numbering-assign auto"
(let ((window-numbering-windows (make-vector 10 nil))
(window-numbering-numbers (make-hash-table :size 10))
(window-numbering-left '(1 2 3 4)))
(assert-eq 1 (window-numbering-assign 'xx))
(assert-nonnil (window-numbering-assign 'yy 3))
(assert-eq 2 (window-numbering-assign 'zz))
(assert-eq 4 (window-numbering-assign 'aa))
))
(deftest "window-numbering-calculate-left"
(assert-equal '(6) (window-numbering-calculate-left
[t t t t t nil t t t t]))
(assert-equal '(1 2 3) (window-numbering-calculate-left
[nil nil nil t t t t t t t]))
(assert-equal '(1 2 3 4 5 6 7 8 9 0)
(window-numbering-calculate-left
[nil nil nil nil nil nil nil nil nil nil]))
)

View file

@ -87,6 +87,9 @@ return a number to have it assigned to the current-window, nil otherwise."
"Face used for the number in the mode-line."
:group 'window-numbering)
(defvar window-numbering-table nil
"table -> (window vector . number table)")
(defun select-window-by-number (i &optional arg)
"Select window given number I by `window-numbering-mode'.
If prefix ARG is given, delete the window instead of selecting it."
@ -107,9 +110,6 @@ If prefix ARG is given, delete the window instead of selecting it."
(interactive "P")
(select-window-by-number ,i arg))))
(defvar window-numbering-table nil
"table -> (window vector . number table)")
(defun window-numbering-calculate-left (windows)
(let ((i 9) left)
(while (>= i 0)