gco / emacs-evernote-mode

Automatically exported from code.google.com/p/emacs-evernote-mode
0 stars 0 forks source link

evernote-browsing-refresh does not work for note-list #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. open a note with evernote-open-note for the first time in the emacs current 
process.
   the note-list buffer *ENB All notes* or *ENB Notes with tag: xxx* is created.
2. save the note.
3. switch to the note-list bufffer, and hit 'l' to invoke 
evernote-browsing-refresh.

What is the expected output? What do you see instead?
It is expected that information in the note-list is updated,
but it remains old.

What version of the product are you using? On what operating system?
- emacs-evernote-mode version
0.40
- Ruby version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
- Emacs version
GNU Emacs 23.2.1 (i386-mingw-nt6.1.7601)
(private build with some patches)
- Operating system
Windows 7 Professional Service Pack 1 (64bit)

Please provide any additional information below.
I wrote a quick dirty patch bellow.
Please ignore this if some refactoring is planned.

--- evernote-mode.el.orig   Fri Jun 24 22:12:08 2011
+++ evernote-mode.el    Sat Jul 09 17:11:41 2011
@@ -189,7 +189,7 @@
 (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 "l"    'evernote-browsing-refresh)
 ;(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)
@@ -289,7 +289,9 @@
     (enh-browsing-push-page
      (enh-browsing-create-page 'note-list
                                (format "Query Result of: %s" query)
-                               note-attrs))))
+                               note-attrs
+                               `(enh-command-get-note-attrs-from-query
+                                 ,query)))))

 (defun evernote-browsing-prev-page ()
@@ -330,10 +332,12 @@
     (switch-to-buffer evernote-browsing-current-page)))

-(defun evernote-browsing-reflesh ()
+(defun evernote-browsing-refresh ()
   (interactive)
   (if (called-interactively-p) (enh-clear-onmem-cache))
   (when (eq major-mode 'evernote-browsing-mode)
+    (when enh-browsing-page-data-refresh-closure
+      (setq enh-browsing-page-data nil))
     (funcall enh-browsing-page-setup-func)))

@@ -586,7 +590,9 @@
                                     (format "Notes with tag: %s"
                                             (enh-tag-guids-to-comma-separated-names tag-guids))
                                   "All notes")
-                                note-attrs)
+                                note-attrs
+                                
`(enh-command-get-note-attrs-from-notebook-and-tag-guids
+                                  ,notebook-guid ,tag-guids))
       t))))

@@ -611,7 +617,9 @@
        (enh-browsing-push-page
         (enh-browsing-create-page 'note-list
                                   (format "Query Result of: %s" query)
-                                  note-attrs)
+                                  note-attrs
+                                  `(enh-command-get-note-attrs-from-query
+                                    ,query))
         t)))))

@@ -630,7 +638,9 @@
       (enh-browsing-create-page 'note-list
                                 (format "Query Result of Saved Search: %s"
                                         (enutil-aget 'name search-attr))
-                                note-attrs)
+                                note-attrs
+                                `(enh-command-get-note-attrs-from-query
+                                  ,(enutil-aget 'query search-attr)))
       t))))

@@ -702,7 +712,7 @@
              evernote-note-modified-notebook-guid
              evernote-note-is-modified-tag-names
              evernote-note-modified-edit-mode)
-         (enh-browsing-reflesh-page 'note-list))
+         (enh-browsing-refresh-page 'note-list))
      (setq evernote-note-modified-name nil
            evernote-note-modified-notebook-guid nil
            evernote-note-is-modified-tag-names nil
@@ -824,7 +834,7 @@
   (let ((name (read-string "Notebook Name:")))
     (enh-command-with-auth
      (enh-command-create-notebook name nil))
-    (enh-browsing-reflesh-page 'notebook-list)))
+    (enh-browsing-refresh-page 'notebook-list)))

 (defun evernote-edit-notebook ()
@@ -846,7 +856,7 @@
                    (enutil-aget 'name notebook-attr))
       (yes-or-no-p "Use as the default notebook:"))))
   (clrhash enh-notebook-info)
-  (enh-browsing-reflesh-page 'notebook-list))
+  (enh-browsing-refresh-page 'notebook-list))

 (defun evernote-create-search ()
@@ -857,7 +867,7 @@
         (query (read-string "Query:")))
     (enh-command-with-auth
      (enh-command-create-search name query))
-    (enh-browsing-reflesh-page 'search-list)))
+    (enh-browsing-refresh-page 'search-list)))

 (defun evernote-edit-search ()
@@ -880,7 +890,7 @@
       (read-string "New Query:"
                    (enutil-aget 'query search-attr)))))
   (clrhash enh-search-info)
-  (enh-browsing-reflesh-page 'search-list))
+  (enh-browsing-refresh-page 'search-list))

 (defun evernote-toggle-read-only ()
@@ -1365,6 +1375,9 @@
 (defvar enh-browsing-page-data nil)
 (make-variable-buffer-local 'enh-browsing-page-data)

+(defvar enh-browsing-page-data-refresh-closure nil)
+(make-variable-buffer-local 'enh-browsing-page-data-refresh-closure)
+
 (defvar enh-browsing-page-widget-title nil)
 (make-variable-buffer-local 'enh-browsing-page-widget-title)

@@ -1388,7 +1401,9 @@
                                (format "Notes in Notebook: %s"
                                        (enutil-aget 'name
                                                     (enh-get-notebook-attr guid)))
-                               note-attrs))))
+                               note-attrs
+                               
`(enh-command-get-note-attrs-from-notebook-and-tag-guids
+                                 ,guid nil)))))

 (defun enh-browsing-open-tag (widget &rest ignored)
@@ -1410,7 +1425,11 @@
                                            (enutil-aget 'name
                                                         (enh-get-tag-attr guid)))
                                  "All notes")
-                               note-attrs))))
+                               note-attrs
+                               
`(enh-command-get-note-attrs-from-notebook-and-tag-guids
+                                 nil ,(if guid
+                                          (list guid)
+                                        nil))))))

 (defun enh-browsing-open-search (widget &rest ignored)
@@ -1428,7 +1447,10 @@
                                (format "Query Result of Saved Search: %s"
                                        (enutil-aget 'name
                                                     (enh-get-search-attr guid)))
-                               note-attrs))))
+                               note-attrs
+                               `(enh-command-get-note-attrs-from-query
+                                 ,(enutil-aget 'query
+                                               (enh-get-search-attr guid)))))))

 (defun enh-browsing-open-note (widget &rest ignored)
@@ -1460,14 +1482,15 @@
      (funcall enh-browsing-page-setup-func))))

-(defun enh-browsing-create-page (type description &optional note-attrs)
+(defun enh-browsing-create-page (type description &optional note-attrs 
refresh-closure)
   "Create a page structure of the attr-list"
   (let ((buf (generate-new-buffer (format "*ENB %s* " description))))
     (save-excursion
       (set-buffer buf)
       (setq enh-browsing-page-type type
             enh-browsing-page-description description
-            enh-browsing-page-data note-attrs)
+            enh-browsing-page-data note-attrs
+            enh-browsing-page-data-refresh-closure refresh-closure)
       (cond
        ((eq type 'notebook-list)
         (setq enh-browsing-page-setup-func
@@ -1596,6 +1619,13 @@
   (when enh-browsing-page-widget-root
     (widget-delete enh-browsing-page-widget-root)
     (setq enh-browsing-page-widget-root nil))
+  (when (and (null enh-browsing-page-data)
+             enh-browsing-page-data-refresh-closure)
+    (let (note-attrs
+          (attrs-func (car enh-browsing-page-data-refresh-closure))
+          (attrs-args (cdr enh-browsing-page-data-refresh-closure)))
+      (setq note-attrs (apply attrs-func attrs-args))
+      (setq enh-browsing-page-data note-attrs)))
   (let ((note-attrs enh-browsing-page-data)
         (note-list nil))
     (mapc
@@ -1671,14 +1701,16 @@
     result))

-(defun enh-browsing-reflesh-page (type)
-  "Reflesh current page"
+(defun enh-browsing-refresh-page (type)
+  "Refresh current page"
   (enh-browsing-update-page-list)
   (save-excursion
     (mapcar (lambda (page)
               (set-buffer page)
-              (if (eq enh-browsing-page-type type)
-                  (funcall enh-browsing-page-setup-func)))
+              (when (eq enh-browsing-page-type type)
+                (when enh-browsing-page-data-refresh-closure
+                  (setq enh-browsing-page-data nil))
+                (funcall enh-browsing-page-setup-func)))
             evernote-browsing-page-list)))

 ;
@@ -2135,7 +2167,7 @@
              tag-guids)
             nil)
       (enh-clear-onmem-cache)
-      (enh-browsing-reflesh-page 'tag-list))))
+      (enh-browsing-refresh-page 'tag-list))))

 (defun enh-tag-guids-to-comma-separated-names (tag-guids &optional maxlen)

Original issue reported on code.google.com by highmtwo...@gmail.com on 9 Jul 2011 at 8:44

GoogleCodeExporter commented 9 years ago
I am sorry for wrong lines bellow:

> - emacs-evernote-mode version
> 0.40

0.41 is correct.

Original comment by highmtwo...@gmail.com on 9 Jul 2011 at 8:48

GoogleCodeExporter commented 9 years ago
Thank you very much for sending the patch!
I applied the patch at r195.

Original comment by kawakami...@gmail.com on 10 Jul 2011 at 3:09