stop extra newlines problem when re-indenting code
authorD Herring <dherring@at.tentpost.dot.com>
Thu, 7 Jun 2012 16:37:07 +0000 (01:37 +0900)
committerD Herring <dherring@at.tentpost.dot.com>
Sat, 23 Jun 2012 12:36:57 +0000 (08:36 -0400)
complements the fix to ltk:save-text to strip Tk's extra newline at the end
of the buffer

main.lisp

index 0310370..1648f5e 100644 (file)
--- a/main.lisp
+++ b/main.lisp
         (let ((new-str (format-lisp-form block))
               (start-index (strpos-to-textidx str start))
               (end-index (strpos-to-textidx str end)))
+          ;; the pretty printer likes adding extra newlines (see e.g. http://www.clisp.org/impnotes/faq.html#faq-pp-newline)
+          ;; these generally aren't appropriate when just changing indentation...
+          #| leaves two steps in the undo history:
           (ltk::delete-text txt start-index end-index)
-          (ltk::insert-text txt new-str)
+          (let ((*print-pretty* nil))
+            (ltk::insert-text txt new-str))
+          |#
+          (let ((*print-pretty* nil))
+            (ltk::format-wish "~a replace ~a ~a \"~a\"" (ltk::widget-path txt) start-index end-index (ltk::tkescape new-str)))
           (apply-highlight txt start-index end-index)))
       (error (ex) (error-message ex)))))