[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: .w3m/.sessions too damn big



青田です。

jidanni@xxxxxxxxxxx writes:

> # ls -og .w3m/.sessions
> -rw-r--r-- 1 1088225 2009-02-22 09:24 /home/jidanni/.w3m/.sessions
> after only a day of browsing.
> Emacs was slowing down.
> OK, I deleted it and did
> (setq
>  ;;w3m-session-file /dev/null?
>  w3m-session-crash-recovery nil
>  w3m-session-deleted-keep-number 0
>  w3m-session-automatic-keep-number 0
>  w3m-session-autosave nil)
> which seems to have stopped it from growing.
> (No, I've never tired the sessions feature. All I know is that I'm not
> the kind of person to remember to quit with a Q).
>
> By the way, in (info "(emacs-w3m)Session Manager")
>
>   If `w3m-session-automatic-save' is non-`nil', emacs-w3m saves the
>   opened sessions automatically when quitting emacs-w3m.
>
> You mean `w3m-session-autosave'. `w3m-session-automatic-save' is a
> function.

.w3m/.sessions が大きくなりすぎてそのため Emacs の動きが遅くなってしまう、
という話。 クラッシュ復元機能のためにページを開くごとにセッションを保存
していることと、 w3m-history-flat も保存していることがこの巨大化の原因だ
と思います。

そこで w3m-history-slimed-history-flat() という関数を追加して slim した
history-flat を保存するようにしようと思うのですがいかがでしょうか?

w3m-history-slimed-history-flat() は、 emacs-w3m の履歴ツリーを他のブラウ
ザの履歴のように "Next" と "Prev" だけでたどれるページのみのツリーにして
しまうものです。

--
青田

Index: w3m-hist.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-hist.el,v
retrieving revision 1.61
diff -u -r1.61 w3m-hist.el
--- w3m-hist.el	20 Jul 2008 04:13:20 -0000	1.61
+++ w3m-hist.el	1 Mar 2009 12:47:56 -0000
@@ -655,6 +655,34 @@
 	    w3m-history (list (list nil (list 0) nil)
 			      (list (car element) (cadr element)))))))
 
+(defun w3m-history-slimed-history-flat (history-flat)
+  "Slim the given `w3m-history-flat'."
+  (let ((position (caddar history-flat))
+	flat-map new-flat)
+    (dolist (l history-flat)
+      (setq flat-map (cons (cons (nth 2 l) l)
+			   flat-map)))
+    (setq new-flat (cons (cdr (assoc position flat-map)) nil))
+    (let ((pos (w3m-history-previous-position position)))
+      (while pos
+	(setq new-flat (cons (cdr (assoc pos flat-map))
+			     new-flat))
+	(setq pos (w3m-history-previous-position pos))))
+    (let ((pos (w3m-history-next-position position)))
+      (while pos
+	(setq new-flat (cons (cdr (assoc pos flat-map))
+			     new-flat))
+	(setq pos (w3m-history-next-position pos))))
+    new-flat))
+
+(defun w3m-history-slim ()
+  "Slim the history.
+This make the history one in normal brosers."
+  (interactive)
+  (let ((position (caddar w3m-history-flat)))
+    (setq w3m-history-flat (w3m-history-slimed-history-flat w3m-history-flat))
+    (w3m-history-tree position)))
+
 (eval-when-compile
   (defvar w3m-arrived-db)
   (autoload 'w3m-goto-url "w3m"))
Index: w3m-session.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-session.el,v
retrieving revision 1.26
diff -u -r1.26 w3m-session.el
--- w3m-session.el	26 Feb 2009 01:56:36 -0000	1.26
+++ w3m-session.el	1 Mar 2009 12:47:57 -0000
@@ -169,7 +169,7 @@
      (mapcar (lambda (x)
 	       (unless (equal (nth 2 x) pos)
 		 (list x)))
-	     (copy-sequence w3m-history-flat)))))
+	     (copy-sequence (w3m-history-slimed-history-flat w3m-history-flat))))))
 
 ;; format of sessin file.
 ;; '((sessiontitle1 time1 ((url11 pos11 hflat11 urltitle11)