branch: elpa/aidermacs commit 8ecfa8cbd71eab85ab2ede6bd0eb82e48c521e6d Author: Mingde (Matthew) Zeng <matthew...@posteo.net> Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>
Restore aidermacs-send-region-by-line Signed-off-by: Mingde (Matthew) Zeng <matthew...@posteo.net> --- aidermacs.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/aidermacs.el b/aidermacs.el index 91a6d31980..a0cf7b802b 100644 --- a/aidermacs.el +++ b/aidermacs.el @@ -221,7 +221,7 @@ This function sets up the appropriate arguments and launches the process." (aidermacs--setup-ediff-cleanup-hooks) (aidermacs--setup-cleanup-hooks) (aidermacs-setup-minor-mode) - + (let* ((buffer-name (aidermacs-get-buffer-name)) ;; Process extra args: split each string on whitespace. (flat-extra-args @@ -1046,14 +1046,19 @@ Otherwise, send the line under cursor." (when text (aidermacs--send-command text)))) -(defun aidermacs-send-region-by-line (start end) - "Send the text between START and END, line by line." - (interactive "r") - (with-restriction start end - (save-excursion - (goto-char (point-min)) - (while (search-forward "^[[:space:]]*\\([^[:space:]].*\\)[[:space:]]*$" nil t) - (aidermacs--send-command (match-string 1)))))) +(defun aidermacs-send-region-by-line () + "Send the text of the current selected region, split into lines." + (interactive) + (if (use-region-p) + (let* ((text (buffer-substring-no-properties + (region-beginning) (region-end))) + (lines (split-string text "\n" t))) + (mapc (lambda (line) + (let ((trimmed (string-trim line))) + (when (not (string-empty-p trimmed)) + (aidermacs--send-command trimmed)))) + lines)) + (message "No region selected."))) (defun aidermacs-send-block-or-region () "Send the current active region text or current paragraph content.