From e77b950a73e0c6ae4246d4e5f219202df433732f Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 31 Jul 2021 19:59:09 -0500 Subject: Rewrite kill-ring-save-unfilled --- lisp/acdw.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lisp/acdw.el b/lisp/acdw.el index 2d98833..9d8c489 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -91,11 +91,16 @@ ARG). When called with multiple arguments or a list, it returns "Unfill, kill, then re-fill the region defined by START and END positions. REGION is passed straight to `kill-ring-save'." (interactive "*r") - (save-excursion - (save-restriction - (unfill-region start end) - (kill-ring-save start end region) - (fill-region start end)))) + (let ((sentence-end-double-space nil)) + (unfill-region start end) + (kill-ring-save + ;; A quick hack to try and ameliorate the "Args out of range" error when + ;; `unfill-region' removes some newlines. I'm not sure if this will work + ;; if calling from Lisp or other such nonsense. + (max start (point-min)) + (min end (point-max)) + region)) + (fill-region start end)) (defmacro when-unfocused (name &rest forms) "Define a function NAME, executing FORMS, that fires when Emacs -- cgit 1.4.1-21-gabe81