summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2010-01-13 13:32:19 +1100
committerKevin Ballard <kevin@sb.org>2010-01-13 13:32:19 +1100
commitee8e92b3022ed1204c7f18a961b61b5da3f9f772 (patch)
tree82ab4a51eacfd23c28a47e1cb3c2a6dfeae9b9b3
parent784032618f229fdf60b3fc75d30450252aea285c (diff)
downloadgolang-ee8e92b3022ed1204c7f18a961b61b5da3f9f772.tar.gz
Fix minor issues with updating go-mode in an empty buffer
Sometimes during editing, when the buffer is emptied (for example, as part of a call to M-x gofmt), an error is raised when remove-text-properties is called. Ensure that these calls use point-max instead of buffer-size to determine their end point. R=golang-dev, r CC=golang-dev http://codereview.appspot.com/189042 Committer: Rob Pike <r@golang.org>
-rw-r--r--misc/emacs/go-mode.el18
1 files changed, 10 insertions, 8 deletions
diff --git a/misc/emacs/go-mode.el b/misc/emacs/go-mode.el
index 8d103d05f..e27ee7438 100644
--- a/misc/emacs/go-mode.el
+++ b/misc/emacs/go-mode.el
@@ -179,14 +179,16 @@ marked from the beginning up to this point.")
"An after-change-function that clears the comment/string and
nesting caches from the modified point on."
- (when (< b go-mode-mark-cs-end)
- (remove-text-properties b (min go-mode-mark-cs-end (buffer-size)) '(go-mode-cs nil))
- (setq go-mode-mark-cs-end b
- go-mode-mark-cs-state nil))
+ (save-restriction
+ (widen)
+ (when (< b go-mode-mark-cs-end)
+ (remove-text-properties b (min go-mode-mark-cs-end (point-max)) '(go-mode-cs nil))
+ (setq go-mode-mark-cs-end b
+ go-mode-mark-cs-state nil))
- (when (< b go-mode-mark-nesting-end)
- (remove-text-properties b (min go-mode-mark-nesting-end (buffer-size)) '(go-mode-nesting nil))
- (setq go-mode-mark-nesting-end b)))
+ (when (< b go-mode-mark-nesting-end)
+ (remove-text-properties b (min go-mode-mark-nesting-end (point-max)) '(go-mode-nesting nil))
+ (setq go-mode-mark-nesting-end b))))
(defmacro go-mode-parser (&rest body)
"Evaluate BODY in an environment set up for parsers that use
@@ -463,7 +465,7 @@ functions, and some types. It also provides indentation that is
;; Remove stale text properties
(save-restriction
(widen)
- (remove-text-properties 1 (+ (buffer-size) 1)
+ (remove-text-properties 1 (point-max)
'(go-mode-cs nil go-mode-nesting nil)))
;; Reset the syntax mark caches