Browse code

stop extra newlines problem when re-indenting code

complements the fix to ltk:save-text to strip Tk's extra newline at the end
of the buffer

D Herring authored on 2012-06-07 16:37:07
Showing 1 changed files
... ...
@@ -208,8 +208,15 @@
208 208
         (let ((new-str (format-lisp-form block))
209 209
               (start-index (strpos-to-textidx str start))
210 210
               (end-index (strpos-to-textidx str end)))
211
+          ;; the pretty printer likes adding extra newlines (see e.g. http://www.clisp.org/impnotes/faq.html#faq-pp-newline)
212
+          ;; these generally aren't appropriate when just changing indentation...
213
+          #| leaves two steps in the undo history:
211 214
           (ltk::delete-text txt start-index end-index)
212
-          (ltk::insert-text txt new-str)
215
+          (let ((*print-pretty* nil))
216
+            (ltk::insert-text txt new-str))
217
+          |#
218
+          (let ((*print-pretty* nil))
219
+            (ltk::format-wish "~a replace ~a ~a \"~a\"" (ltk::widget-path txt) start-index end-index (ltk::tkescape new-str)))
213 220
           (apply-highlight txt start-index end-index)))
214 221
       (error (ex) (error-message ex)))))
215 222