Explorar el Código

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 hace 15 años
padre
commit
a5560e0287
Se han modificado 1 ficheros con 13 adiciones y 2 borrados
  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))