From d5b635f34e3d5ad9b380535d1f07084a91074883 Mon Sep 17 00:00:00 2001 From: Nikolaj Schumacher Date: Mon, 2 Sep 2013 18:10:36 +0200 Subject: [PATCH 1/4] Convert tests to ERT. --- window-numbering-tests.el | 64 ++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/window-numbering-tests.el b/window-numbering-tests.el index b897a97..54a6ea2 100644 --- a/window-numbering-tests.el +++ b/window-numbering-tests.el @@ -1,35 +1,37 @@ -(require 'elk-test) +(require 'ert) +(require 'window-numbering) -(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)) -)) +(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))) + )) -(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])) +(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]))) ) From 427d0d0b29c56e340a6dc063331fa627280eca9c Mon Sep 17 00:00:00 2001 From: Nikolaj Schumacher Date: Mon, 2 Sep 2013 18:13:43 +0200 Subject: [PATCH 2/4] Fix undefined variable compiler warning. --- window-numbering.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window-numbering.el b/window-numbering.el index 30e67aa..702c334 100644 --- a/window-numbering.el +++ b/window-numbering.el @@ -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) From 24f7ea3944455c9fc89f969059cfe5ec179d990c Mon Sep 17 00:00:00 2001 From: Nikolaj Schumacher Date: Mon, 2 Sep 2013 18:22:07 +0200 Subject: [PATCH 3/4] Add .travis.yml. --- .travis.yml | 40 +++++++++++++++++++++++++++ window-numbering-tests.el => tests.el | 0 2 files changed, 40 insertions(+) create mode 100644 .travis.yml rename window-numbering-tests.el => tests.el (100%) diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..46049fd --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/window-numbering-tests.el b/tests.el similarity index 100% rename from window-numbering-tests.el rename to tests.el From 87b29e6123b716abaaeefa1ef03c3702cb0ba882 Mon Sep 17 00:00:00 2001 From: Nikolaj Schumacher Date: Mon, 2 Sep 2013 18:26:58 +0200 Subject: [PATCH 4/4] Add basic README. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f0aa4b9 --- /dev/null +++ b/README.md @@ -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)))