From: ueno Date: Sat, 30 Oct 2004 00:59:45 +0000 (+0000) Subject: * riece-yank.el (riece-yank-strip-space): New user option. X-Git-Tag: riece-1_0_5~14 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13dddb8a8a45cb2c0755f292e1d28ac7a45ba37a;p=elisp%2Friece.git * riece-yank.el (riece-yank-strip-space): New user option. (riece-command-yank): Strip spaces if riece-yank-strip-space is non-nil. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4664edc..a70a008 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2004-10-30 Daiki Ueno + + * riece-yank.el (riece-yank-strip-space): New user option. + (riece-command-yank): Strip spaces if riece-yank-strip-space is + non-nil. + 2004-10-18 Daiki Ueno * riece-yank.el: New add-on from Masatake YAMATO . diff --git a/lisp/riece-yank.el b/lisp/riece-yank.el index e92f499..8817f5e 100644 --- a/lisp/riece-yank.el +++ b/lisp/riece-yank.el @@ -39,6 +39,12 @@ :type 'number :group 'riece-yank) +(defcustom riece-yank-strip-space nil + "If non-nil, strip common spaces in front of lines and blank lines +before/after the first/last non-blank line." + :type 'boolean + :group 'riece-yank) + (defvar riece-yank-enabled nil) (defun riece-yank-insinuate () @@ -60,6 +66,28 @@ msg) (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 msg (split-string kill "\n")) (when (y-or-n-p (format "Send \"%s\"\n? " kill)) (mapcar