diff lisp/emulation/viper-cmd.el @ 74857:2e5f946f7726

2006-12-23 Michael Kifer <kifer@cs.stonybrook.edu> * ediff-diff.el (ediff-diff-options): clarify docstring. (ediff-setup-diff-regions): disallow -u in ediff-diff-options. * viper-cmd.el (viper-post-command-sentinel): protect against errors in hooks. (viper-add-newline-at-eob-if-necessary): add newline only if we actually modify buffer; ignore errors if occur.
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 23 Dec 2006 21:33:50 +0000
parents db25befb2938
children 7a3f13e2dd57 bc10a33dd40b
line wrap: on
line diff
--- a/lisp/emulation/viper-cmd.el	Sat Dec 23 20:11:10 2006 +0000
+++ b/lisp/emulation/viper-cmd.el	Sat Dec 23 21:33:50 2006 +0000
@@ -171,7 +171,9 @@
   (run-hook-with-args 'viper-before-change-functions beg end))
 
 (defsubst viper-post-command-sentinel ()
-  (run-hooks 'viper-post-command-hooks)
+  (condition-case conds
+      (run-hooks 'viper-post-command-hooks)
+    (error (viper-message-conditions conds)))
   (if (eq viper-current-state 'vi-state)
       (viper-restore-cursor-color 'after-insert-mode)))
 
@@ -926,8 +928,7 @@
 
     (condition-case nil
 	(let (viper-vi-kbd-minor-mode) ; execute without kbd macros
-	  (setq result (eval form))
-	  )
+	  (setq result (eval form)))
       (error
        (signal 'quit nil)))
 
@@ -1971,9 +1972,16 @@
 	(if (and (eobp)
 		 (not (bolp))
 		 require-final-newline
+		 ;; add newline only if we actually edited buffer. otherwise it
+		 ;; might unintentionally modify binary buffers
+		 (buffer-modified-p) 
 		 (not (viper-is-in-minibuffer))
 		 (not buffer-read-only))
-	    (insert "\n")))
+	    ;; text property may be read-only
+	    (condition-case nil
+		(insert "\n")
+	      (error nil))
+	  ))
       ))
 
 (defun viper-yank-defun ()