branch: elpa/inf-clojure commit 85d3d41fecb9c288f72e88674dae573bc4fd9a66 Author: Bozhidar Batsov <bozhi...@tradeo.com> Commit: Bozhidar Batsov <bozhi...@tradeo.com>
Extract a chomp helper --- inf-clojure.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/inf-clojure.el b/inf-clojure.el index 3a0f3c1..a6e5841 100644 --- a/inf-clojure.el +++ b/inf-clojure.el @@ -233,16 +233,18 @@ to continue it." "t if STR does not match `inf-clojure-filter-regexp'." (not (string-match inf-clojure-filter-regexp str))) +(defun inf-clojure-chomp (string) + (if (string-match "[\n]\\'" string) + (replace-match "" t t string) + string)) + (defun clojure-preoutput-filter (str) "Preprocess the output STR from interactive commands." - (if (string-prefix-p "clojure-" (symbol-name (or this-command last-command))) - ;; prepend a newline to the output string - (let ((string (concat "\n" str))) - ;; strip the extra trailing newline - (if (string-match "[\n]+\\'" string) - (replace-match "" t t string) - string)) - str)) + (cond + ((string-prefix-p "clojure-" (symbol-name (or this-command last-command))) + ;; prepend a newline to the output string + (inf-clojure-chomp (concat "\n" str))) + (t str))) ;;;###autoload (defun inf-clojure (cmd)