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

Re: recentre anchor at top of window



From: Katsumi Yamaoka <yamaoka@xxxxxxx> さん曰く
Subject: [emacs-w3m:10839] Re: recentre anchor at top of window
Message-ID: <b4miqkxo141.fsf@xxxxxxx>
Date: Wed, 22 Apr 2009 11:47:58 +0900

> Now w3m-search-name-anchor, w3m-view-this-url-1, w3m-next-anchor,
> w3m-previous-anchor, w3m-next-form, w3m-previous-form,
> w3m-next-image, and w3m-previous-image work with it.  Suggestions
> to improve this feature are welcome.

ぼくの環境だと、下記のパッチをあてないとだめでした。emacs 22, 23 とも。

最初の (lexical-let ((url url) は、sentinel で上に戻ってきて、
w3m-view-this-url-1 が継続したときに、

"url なんて変数ないぜ"

と(なんでかわからないけど)エラーになることの対応。

二つ目の save-excursion は recenter すると、point が変わって、
w3m-next-anchor() などの w3m-print-this-url() がちゃんと動かない
ことの対応。

です。最初のエラーが良くわからないので、お任せです (__)

-- 
白井秀行 (mailto:shirai@xxxxxxxxxxx)


--- w3m.el.~1.1438.~	2009-04-22 12:06:11.000000000 +0900
+++ w3m.el	2009-04-22 15:12:14.132755000 +0900
@@ -6587,7 +6587,8 @@
   (sit-for 0))
 
 (defsubst w3m-view-this-url-1 (url reload new-session)
-  (lexical-let (pos buffer newbuffer wconfig)
+  (lexical-let ((url url)
+		pos buffer newbuffer wconfig)
     (if new-session
 	(let ((empty
 	       ;; If a new url has the #name portion, we simply copy
@@ -8495,19 +8496,20 @@
 		   (car w3m-view-recenter))
 	       w3m-view-recenter)))
     (when (and val (eq (window-buffer) (current-buffer)))
-      (goto-char
-       (prog1
-	   (point)
-	 ;; A version of `recenter' that does not redisplay the frame.
-	 (let ((height (w3m-static-if (featurep 'xemacs)
-			   (1- (window-height))
-			 (- (window-height) 1 (if header-line-format 1 0)))))
-	   (when (zerop (forward-line (if (integerp val)
-					  (if (< val 0)
-					      (- 0 height val)
-					    (- val))
-					(- (/ height 2)))))
-	     (set-window-start nil (point)))))))))
+      (save-excursion
+	(goto-char
+	 (prog1
+	     (point)
+	   ;; A version of `recenter' that does not redisplay the frame.
+	   (let ((height (w3m-static-if (featurep 'xemacs)
+			     (1- (window-height))
+			   (- (window-height) 1 (if header-line-format 1 0)))))
+	     (when (zerop (forward-line (if (integerp val)
+					    (if (< val 0)
+						(- 0 height val)
+					      (- val))
+					  (- (/ height 2)))))
+	       (set-window-start nil (point))))))))))
 
 (defun w3m-beginning-of-line (&optional arg)
   "Make the beginning of the line visible and move the point to there."