浏览代码

Ensure we "encode" the region before sending it back.

Modes like longlines-mode store data in the buffer differently to how
it will eventually be stored on the file. As we don't actually deal
with files we need to ensure we "encode" the buffer to the right form
before sending the response.

This does open up the intriguing possibility of using emacs to edit
arbitrary elements on the web-page, but for now this is a longlines
thing.
Alex Bennee 15 年之前
父节点
当前提交
a5560e0287
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 13 2
      edit_server.el

+ 13 - 2
edit_server.el

@@ -302,8 +302,19 @@ When called interactively, use prefix arg to abort editing."
           (run-hooks 'edit-server-done-hook)
           (edit-server-send-response proc t))
       ;; send back edited content
-      (run-hooks 'edit-server-done-hook)
-      (edit-server-send-response edit-server-proc t))
+      (save-restriction
+	(widen)
+	(buffer-disable-undo)
+	;; ensure any format encoding is done (like longlines)
+	(dolist (format buffer-file-format)
+	  (format-encode-region (point-min) (point-max) format))
+	;; send back
+	(run-hooks 'edit-server-done-hook)
+	(edit-server-send-response edit-server-proc t)
+	;; restore formats (only useful if we keep the buffer)
+	(dolist (format buffer-file-format)
+	  (format-decode-region (point-min) (point-max) format))
+	(buffer-enable-undo)))
     (if edit-server-frame (delete-frame edit-server-frame))
     ;; delete-frame may change the current buffer
     (unless nokill (kill-buffer buffer))