             search-alist
             nil t)
            search-alist))))
-      t))))
+      t)
+     t)))
 
 
 (defun evernote-open-note-common (note-command-output &optional display-completion)

  (if (and evernote-note-guid (buffer-modified-p))
      (evernote-command-with-auth
       (lambda ()
         (progn
           (evernote-command-update-note
            (current-buffer)
            evernote-note-guid
            evernote-note-name
            evernote-note-tags
            evernote-note-edit-mode)
           (set-buffer-modified-p nil))))
    (message "(No changes need to be saved)")))



        (read-string "New Saved search name:"
                     (evernote-assoc-cdr 'name search-attr))
        (read-string "New Query:"
                     (evernote-assoc-cdr 'query search-attr))))
     t)))


;;
;; Helper functions.
;;

;;(defun evernote-command-with-auth (func &rest args)
;;  "Add or remove tags from/to the note"
;;  (let ((error-code (catch 'error (apply func args))))
;;    (if (or (eq error-code evernote-error-invalid-auth)
;;            (eq error-code evernote-error-auth-expired))
;;        (let ((error-code (catch 'error (evernote-command-login))))
;;          (if (eq error-code t)
;;              (apply func args)
;;            (message "%s (%s)"
;;                     (evernote-error-message error-code)
;;                     (evernote-get-first-line
;;                      (evernote-get-command-result)))))
;;      (message "%s (%s)"
;;               (evernote-error-message error-code)
;;               (evernote-get-first-line
;;                (evernote-get-command-result))))))


(defun evernote-command-with-auth (func &rest args)
  "Add or remove tags from/to the note"
  (let ((error-code (catch 'error (apply func args))))
    (cond
     ((eq error-code t)
      t)
     ((or (eq error-code evernote-error-invalid-auth)
          (eq error-code evernote-error-auth-expired))
      (let ((error-code (catch 'error (evernote-command-login))))
        (if (eq error-code t)
            (progn
              (let ((error-code (catch 'error (apply func args))))
                (if (not (eq error-code t))
                    (evernote-output-error-message error-code))))
          (evernote-output-error-message error-code))))
     (t
      (evernote-output-error-message error-code)))))


(defun evernote-output-error-message (error-code)
  (message "%s (%s)"
           (evernote-error-message error-code)
           (evernote-get-first-line
            (evernote-get-command-result))))


(defun evernote-get-tag-alist (tag-command-out)
