Forráskód Böngészése

edit-server.el: persist the buffer-local variables beyond mode changes

As discussed in https://github.com/stsquad/emacs_chrome/issues/37 a
change in major mode after setting up can loose critical information.
The normal major mode selection tries to mitigate against this by
making sure those mode changes happen early on.

If you change major-mode you'll still need to re-enable the
edit-server-edit-mode to re-enable the key map that allows you to save
your progress.

Written-by: frobtech
Alex Bennee 13 éve
szülő
commit
6bdffe5b7d
1 módosított fájl, 15 hozzáadás és 0 törlés
  1. 15 0
      edit-server.el

+ 15 - 0
edit-server.el

@@ -140,32 +140,47 @@ major mode. If no pattern matches,
 (defconst edit-server-edit-buffer-name "TEXTAREA"
 	"Template name of the edit-server text editing buffers.")
 
+;; Buffer local variables
+;
+; These are all required to associate the edit buffer with the
+; correct connection to the client and allow for the buffer to be sent
+; back when ready. They are `permanent-local` to avoid being reset if
+; the buffer changes major modes.
+
 (defvar edit-server-proc 'nil
 	"Network process associated with the current edit, made local when
  the edit buffer is created")
+(put 'edit-server-proc 'permanent-local t)
 
 (defvar edit-server-frame 'nil
 	"The frame created for a new edit-server process, made local when
  then edit buffer is created")
+(put 'edit-server-frame 'permanent-local t)
 
 (defvar edit-server-clients '() 
 	"List of all client processes associated with the server process.")
+(put 'edit-server-clients 'permanent-local t)
 
 (defvar edit-server-phase nil 
 	"Symbol indicating the state of the HTTP request parsing.")
+(put 'edit-server-phase 'permanent-local t)
 
 (defvar edit-server-received nil 
 	"Number of bytes received so far in the client buffer. 
 Depending on the character encoding, may be different from the buffer length.")
+(put 'edit-server-received 'permanent-local t)
 
 (defvar edit-server-request nil 
 	"The HTTP request (GET, HEAD, POST) received.")
+(put 'edit-server-request 'permanent-local t)
 
 (defvar edit-server-content-length nil 
 	"The value gotten from the HTTP `Content-Length' header.")
+(put 'edit-server-content-length 'permanent-local t)
 
 (defvar edit-server-url nil 
 	"The value gotten from the HTTP `x-url' header.")
+(put 'edit-server-url 'permanent-local t)
 
 ;; Mode magic
 ;