From: Daiki Ueno Date: Sun, 7 Nov 2004 00:22:32 +0000 (+0000) Subject: * riece-yank.el (riece-yank-strip-space): New function split from X-Git-Url: http://cgit.sxemacs.org/?p=riece;a=commitdiff_plain;h=a47568b9565c70082b6fc90d58c66e7b85ab8d58 * riece-yank.el (riece-yank-strip-space): New function split from riece-command-yank. * test/test-riece-addon.el: New test cases. * test/test-riece-yank.el: New test cases. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a3a3aae..c556c6c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2004-11-07 Daiki Ueno + + * riece-yank.el (riece-yank-strip-space): New function split from + riece-command-yank. + * test/test-riece-addon.el: New test cases. + * test/test-riece-yank.el: New test cases. + +2004-11-05 Daiki Ueno + + * COMPILE (riece-test): New function. + * Makefile.am (check-local): New target. + * test/luna.el: New file. + * test/lunit.el: New file. + * test/test-riece-alias.el: New test cases. + 2004-11-05 Daiki Ueno * riece-alias.el (riece-alias-alternate-separator): New user diff --git a/lisp/riece-yank.el b/lisp/riece-yank.el index fdb5b34..c774980 100644 --- a/lisp/riece-yank.el +++ b/lisp/riece-yank.el @@ -57,6 +57,29 @@ before/after the first/last non-blank line." (define-key riece-command-mode-map "\C-cy" 'undefined) (setq riece-yank-enabled nil)) +(defun riece-yank-strip-space (string) + (with-temp-buffer + (insert string) + (untabify (point-min) (point-max)) + ;; Delete blank lines before the first non-blank line. + (goto-char (point-min)) + (while (looking-at " *$") + (delete-region (point) (progn (forward-line) (point)))) + ;; Delete blank lines after the last non-blank line. + (goto-char (point-max)) + (while (progn (beginning-of-line) (looking-at " *$")) + (delete-region (point) (progn (end-of-line 0) (point)))) + ;; Delete common spaces in front of lines. + (setq space-width (point-max)) + (while (looking-at " +") + (setq space-width (min space-width (length (match-string 0)))) + (forward-line)) + (goto-char (point-min)) + (while (not (eobp)) + (delete-char space-width) + (forward-line)) + (buffer-string))) + (defun riece-command-yank (prefix) (interactive "sPrefix: ") (when (or (not prefix) @@ -67,27 +90,7 @@ before/after the first/last non-blank line." (unless kill (error "Nothing to send in kill-ring")) (if riece-yank-strip-space - (with-temp-buffer - (insert kill) - (untabify (point-min) (point-max)) - ;; Delete blank lines before the first non-blank line. - (goto-char (point-min)) - (while (looking-at " *$") - (delete-region (point) (progn (forward-line) (point)))) - ;; Delete blank lines after the last non-blank line. - (goto-char (point-max)) - (while (progn (beginning-of-line) (looking-at " *$")) - (delete-region (point) (progn (end-of-line 0) (point)))) - ;; Delete common spaces in front of lines. - (setq space-width (point-max)) - (while (looking-at " +") - (setq space-width (min space-width (length (match-string 0)))) - (forward-line)) - (goto-char (point-min)) - (while (not (eobp)) - (delete-char space-width) - (forward-line)) - (setq kill (buffer-string)))) + (setq kill (riece-yank-strip-space kill))) (setq msg (split-string kill "\n")) (when (y-or-n-p (format "Send \"%s\"\n? " kill)) (mapcar diff --git a/lisp/test/test-riece-addon.el b/lisp/test/test-riece-addon.el new file mode 100644 index 0000000..ba385d1 --- /dev/null +++ b/lisp/test/test-riece-addon.el @@ -0,0 +1,40 @@ +(require 'riece-addon) + +(defun test-riece-addon-1-requires () + '(test-riece-addon-2)) +(provide 'test-riece-addon-1) + +(defun test-riece-addon-2-requires () + '(test-riece-addon-3 test-riece-addon-4)) +(provide 'test-riece-addon-2) + +(defun test-riece-addon-3-requires ()) +(provide 'test-riece-addon-3) + +(defun test-riece-addon-4-requires ()) +(provide 'test-riece-addon-4) + +(defun test-riece-addon-5-requires () + '(test-riece-addon-6)) +(provide 'test-riece-addon-5) + +(defun test-riece-addon-6-requires () + '(test-riece-addon-5)) +(provide 'test-riece-addon-6) + +(luna-define-class test-riece-addon (lunit-test-case)) + +(luna-define-method test-riece-resolve-addons-1 ((case test-riece-addon)) + (lunit-assert + (equal + (riece-resolve-addons '(test-riece-addon-1 test-riece-addon-2)) + '(test-riece-addon-3 test-riece-addon-4 + test-riece-addon-2 test-riece-addon-1)))) + +(luna-define-method test-riece-resolve-addons-2 ((case test-riece-addon)) + (lunit-assert + (equal + (condition-case error + (riece-resolve-addons '(test-riece-addon-5 test-riece-addon-6)) + (error (nth 1 error))) + "Circular add-on dependency found"))) diff --git a/lisp/test/test-riece-alias.el b/lisp/test/test-riece-alias.el index 9ee22ea..b9e363d 100644 --- a/lisp/test/test-riece-alias.el +++ b/lisp/test/test-riece-alias.el @@ -2,6 +2,17 @@ (luna-define-class test-riece-alias (lunit-test-case)) +(luna-define-method test-riece-alias-percent-hack ((case test-riece-alias)) + (let ((riece-alias-percent-hack-mask "*.jp")) + (lunit-assert + (equal + (riece-alias-abbrev-percent-hack "#riece:*.jp") + "%riece")) + (lunit-assert + (equal + (riece-alias-expand-percent-hack "%riece") + "#riece:*.jp")))) + (luna-define-method test-riece-alias-altsep-1 ((case test-riece-alias)) (let ((riece-alias-alternate-separator "@")) (lunit-assert diff --git a/lisp/test/test-riece-yank.el b/lisp/test/test-riece-yank.el new file mode 100644 index 0000000..f41dcc1 --- /dev/null +++ b/lisp/test/test-riece-yank.el @@ -0,0 +1,25 @@ +(require 'riece-yank) + +(luna-define-class test-riece-yank (lunit-test-case)) + +(luna-define-method test-riece-yank-strip-space ((case test-riece-yank)) + (lunit-assert + (equal + (riece-yank-strip-space "\ + def a + 0.times do + 0.times do + p 1 # this line begins with a TAB + end + end + end + +") + "\ +def a + 0.times do + 0.times do + p 1 # this line begins with a TAB + end + end +end")))