       (pop-to-buffer buf))))
 
 
-(defun evernote-create-note-buffer (guid name edit-mode tags content)
+(defun evernote-create-note-buffer (guid name tags edit-mode content)
   "Create new buffer for the note"
   (save-excursion
     (let ((buf (generate-new-buffer name)))
       (set-buffer buf)
       (insert content)
-      (setq evernote-note-guid guid
-            evernote-note-name name
-            evernote-note-edit-mode edit-mode
-            evernote-note-tags tags)
-      (evernote-mode)
+      (evernote-change-major-mode-from-note-name name)
+      (evernote-mode guid name tags edit-mode)
       (goto-char (point-min))
-      (evernote-update-mode-line)
       (set-buffer-modified-p nil)
       (pop-to-buffer buf))))
 

(defvar evernote-note-edit-mode nil
  "Edit mode of the buffer")
(make-variable-buffer-local 'evernote-note-edit-mode)

(defvar evernote-mode-map (make-sparse-keymap)
  "Keymap used in evernote mode.")

   ((eq error-code evernote-error-quota-reached)      "Quota reached")
   ((eq error-code evernote-error-invalid-auth)       "Invalid auth")
   ((eq error-code evernote-error-auth-expired)       "Auth expired")
   ((eq error-code evernote-error-data-conflict)      "Data conflict. The data already exists.")
   ((eq error-code evernote-error-enml-validation)    "Enml validation. Tried to save a note of invalid format.")
   ((eq error-code evernote-error-shared-unavailable) "Shared unavailable")))

