chiark / gitweb /
el/dot-emacs (mdw-maybe-tabify): Fix incorrect region caching.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 31 Dec 2012 05:40:32 +0000 (05:40 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 31 Dec 2012 05:40:32 +0000 (05:40 +0000)
Obviously `tabify' can change the length of the buffer.  So caching its
end position is not very clever.

el/dot-emacs.el

index 2909fdd67da388047d2e61635922e86f610bfa8d..497318a39ddbb75e3df6f402e8a507fb40814d2b 100644 (file)
@@ -647,13 +647,13 @@ (fset 'mdw-do-auto-fill (symbol-function 'do-auto-fill))
 
 (defun mdw-maybe-tabify (s)
   "Tabify or untabify the string S, according to `indent-tabs-mode'."
-  (with-temp-buffer
-    (save-match-data
-      (let ((tabfun (if indent-tabs-mode #'tabify #'untabify)))
+  (let ((tabfun (if indent-tabs-mode #'tabify #'untabify)))
+    (with-temp-buffer
+      (save-match-data
        (insert s "\n")
        (let ((start (point-min)) (end (point-max)))
-         (funcall tabfun start end)
-         (setq s (buffer-substring start (1- end))))))))
+         (funcall tabfun (point-min) (point-max))
+         (setq s (buffer-substring (point-min) (1- (point-max)))))))))
 
 (defun mdw-examine-fill-prefixes (l)
   "Given a list of dynamic fill prefixes, pick one which matches