Просмотр исходного кода

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 лет назад
Родитель
Сommit
6bdffe5b7d
1 измененных файлов с 15 добавлено и 0 удалено
  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"
 (defconst edit-server-edit-buffer-name "TEXTAREA"
 	"Template name of the edit-server text editing buffers.")
 	"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
 (defvar edit-server-proc 'nil
 	"Network process associated with the current edit, made local when
 	"Network process associated with the current edit, made local when
  the edit buffer is created")
  the edit buffer is created")
+(put 'edit-server-proc 'permanent-local t)
 
 
 (defvar edit-server-frame 'nil
 (defvar edit-server-frame 'nil
 	"The frame created for a new edit-server process, made local when
 	"The frame created for a new edit-server process, made local when
  then edit buffer is created")
  then edit buffer is created")
+(put 'edit-server-frame 'permanent-local t)
 
 
 (defvar edit-server-clients '() 
 (defvar edit-server-clients '() 
 	"List of all client processes associated with the server process.")
 	"List of all client processes associated with the server process.")
+(put 'edit-server-clients 'permanent-local t)
 
 
 (defvar edit-server-phase nil 
 (defvar edit-server-phase nil 
 	"Symbol indicating the state of the HTTP request parsing.")
 	"Symbol indicating the state of the HTTP request parsing.")
+(put 'edit-server-phase 'permanent-local t)
 
 
 (defvar edit-server-received nil 
 (defvar edit-server-received nil 
 	"Number of bytes received so far in the client buffer. 
 	"Number of bytes received so far in the client buffer. 
 Depending on the character encoding, may be different from the buffer length.")
 Depending on the character encoding, may be different from the buffer length.")
+(put 'edit-server-received 'permanent-local t)
 
 
 (defvar edit-server-request nil 
 (defvar edit-server-request nil 
 	"The HTTP request (GET, HEAD, POST) received.")
 	"The HTTP request (GET, HEAD, POST) received.")
+(put 'edit-server-request 'permanent-local t)
 
 
 (defvar edit-server-content-length nil 
 (defvar edit-server-content-length nil 
 	"The value gotten from the HTTP `Content-Length' header.")
 	"The value gotten from the HTTP `Content-Length' header.")
+(put 'edit-server-content-length 'permanent-local t)
 
 
 (defvar edit-server-url nil 
 (defvar edit-server-url nil 
 	"The value gotten from the HTTP `x-url' header.")
 	"The value gotten from the HTTP `x-url' header.")
+(put 'edit-server-url 'permanent-local t)
 
 
 ;; Mode magic
 ;; Mode magic
 ;
 ;