From 0b256231f427667067ea5ec3b0b359332bb57591 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Sat, 30 Oct 2004 00:59:44 +0000 Subject: [PATCH] * riece-yank.el (riece-yank-strip-space): New user option. (riece-command-yank): Strip spaces if riece-yank-strip-space is non-nil. --- lisp/ChangeLog | 6 ++++++ lisp/riece-yank.el | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) 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 -- 2.25.1