 ;; Interface for evernote-browsing-mode.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defconst evernote-browsing-mode-buffer-name "*Evernote-Browser*")
-
-(defvar evernote-browsing-mode-map (copy-keymap global-map)
+
+(defvar evernote-browsing-page-list nil
+  "Buffer list of evernote browsing mode.")
+
+(defvar evernote-browsing-current-page nil
+  "Current buffer of evernote browsing mode.")
+
+
+(defvar evernote-browsing-mode-map (copy-keymap widget-keymap)
   "Keymap used in evernote browsing mode.")
-(define-key evernote-browsing-mode-map "\C-m" 'widget-button-press)
 (define-key evernote-browsing-mode-map "t"    'evernote-browsing-list-tags)
 (define-key evernote-browsing-mode-map "S"    'evernote-browsing-list-searches)
 (define-key evernote-browsing-mode-map "s"    'evernote-browsing-search-notes)
 (define-key evernote-browsing-mode-map "b"    'evernote-browsing-prev-page)
 (define-key evernote-browsing-mode-map "f"    'evernote-browsing-next-page)
 (define-key evernote-browsing-mode-map "d"    'evernote-browsing-delete-page)
+(define-key evernote-browsing-mode-map "l"    'evernote-browsing-reflesh)
 ;(define-key evernote-browsing-mode-map "e"    'evernote-browsing-change-edit-mode)
 ;(define-key evernote-browsing-mode-map "r"    'evernote-browsing-rename-note)
 ;(define-key evernote-browsing-mode-map "d"    'evernote-browsing-delete-note)

(defun evernote-browser ()
  "Open an evernote browser"
  (interactive)
  (let ((buf (get-buffer evernote-browsing-mode-buffer-name)))
    (if buf
        (enutil-move-cursor-to-window buf)
      (switch-to-buffer (generate-new-buffer evernote-browsing-mode-buffer-name))
      (evernote-browsing-mode)
      (evernote-browsing-list-tags))))


(defun evernote-browsing-list-tags ()
  "List tags"
  (interactive)
  (when (eq major-mode 'evernote-browsing-mode)
    (enh-command-with-auth
     (enh-init-tag-info)
     (enh-browsing-push-page
      (enh-browsing-create-page 'tag-list "All Tags")))))


(defun evernote-browsing-list-searches ()
  "List saved searches"
  (interactive)
  (when (eq major-mode 'evernote-browsing-mode)
    (enh-command-with-auth
     (enh-init-search-info)
     (enh-browsing-push-page
      (enh-browsing-create-page 'search-list "All Saved Searches")))))


(defun evernote-browsing-search-notes ()
  "Search notes"
  (interactive)
  (when (eq major-mode 'evernote-browsing-mode)
    (let (note-attrs (query (read-string "Query:")))
      (enh-command-with-auth
       (setq note-attrs
             (enh-command-get-note-attrs-from-query query))
       (enh-set-note-attrs note-attrs)
       (enh-browsing-push-page
        (enh-browsing-create-page 'note-list
                                  (format "Query Result of: %s" query)
                                  note-attrs))))))


(defun evernote-browsing-prev-page ()
  "Move to the prev page"
  (interactive)
  (when (eq major-mode 'evernote-browsing-mode)
    (let ((prev-page (enh-browsing-get-prev-page)))
      (if prev-page
          (progn
            (setq enh-browsing-current-page prev-page)
            (enh-browsing-redraw-current-page))
        (message "[No more previous page]")))))



       (enh-command-get-search-attrs))))


(defun enh-update-note-and-new-tag-attrs (note-attr)
  (enh-set-note-attr note-attr)
  (let* ((tag-guids (enutil-aget 'guid note-attr)))
    (if (catch 'result
