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

Re: follow anchors that point shimbun articles



>> On Tue, 25 Sep 2007 07:55:02 +0900
>> yamaoka@xxxxxxx (Katsumi Yamaoka) said as follows:

>> 単純には,「失敗した場合には t を返す」というような関数に制限してやれ
>> ば,browse-url 由来の関数でも大抵は無改造で済ませられるのですが.しか
>> し,「失敗した場合には t を返す」ってのはなあ.なんだかなあ.

>たとえば `nnshimbun-foo-bar-flag' みたいな変数で媒介させるようにすれば、
>ソースコード上で設計意図を明示することはできます。これも、なんだかなあ、
>ではありますが。

まだ比較的まし(かどうか,大分怪しい)案を作ってみました.
w3m-goto-article-function に指定されている関数が 'w3m-goto-url を返した場
合には,emacs-w3m に fallback するという動作をします.

-- 
土屋 雅稔 ( TSUCHIYA Masatoshi )
--- w3m.el	25 Sep 2007 12:30:25 -0000	1.1311
+++ w3m.el	25 Sep 2007 15:42:44 -0000
@@ -9547,13 +9547,13 @@
 
 ;;; w3m-minor-mode
 (defcustom w3m-goto-article-function nil
-  "Function used to visit an article pointed to by a given URL.
-Normally, this is used only when you follow a link in an html article.
-A function set to this variable takes one argument URL.
-
-If the function throws nil, that means the function failed in fetching
-URL, to the catch tag `success', the default function tries to fetch
-URL again.  See `gnus-summary-refer-shimbun-article' in nnshimbun.el."
+  "Function used to visit an article pointed to by a given URL
+in `w3m-minor-mode' buffer.  Normally, this option is used only
+when you follow a link in an html article.  A function set to
+this variable must take one argument URL, and should display the
+specified page.  It may return the symbol `w3m-goto-url' when it
+fails displaying the page.  In this case, either `w3m-goto-url'
+or `w3m-goto-url-new-session' is employed to display the page."
   :group 'w3m
   :type '(radio (const :tag "Use emacs-w3m" nil)
 		(function :value browse-url)))
@@ -9578,14 +9578,13 @@
   (let ((w3m-pop-up-windows nil)
 	(url (w3m-url-valid (w3m-anchor))))
     (cond
-     (url (or (and (functionp w3m-goto-article-function)
-		   (catch 'success
-		     (funcall w3m-goto-article-function url)
-		     t))
-	      (if (and w3m-make-new-session
-		       (not (eq major-mode 'w3m-mode)))
-		  (w3m-goto-url-new-session url)
-		(w3m-goto-url url))))
+     (url (unless (and (functionp w3m-goto-article-function)
+		       (not (eq 'w3m-goto-url
+				(funcall w3m-goto-article-function url))))
+	    (if (and w3m-make-new-session
+		     (not (eq major-mode 'w3m-mode)))
+		(w3m-goto-url-new-session url)
+	      (w3m-goto-url url))))
      ((w3m-url-valid (w3m-image))
       (if (w3m-display-graphic-p)
 	  (w3m-toggle-inline-image)
--- nnshimbun.el	8 Aug 2007 01:07:57 -0000	1.60
+++ nnshimbun.el	25 Sep 2007 15:42:36 -0000
@@ -875,14 +875,13 @@
   (interactive "sURL: ")
   (let ((method (gnus-find-method-for-group gnus-newsgroup-name))
 	(header))
-    (throw
-     'success
-     (and (eq 'nnshimbun (car method))
-	  (nnshimbun-possibly-change-group nil (nth 1 method))
-	  (setq header (nnshimbun-search-xref
-			(gnus-group-short-name gnus-newsgroup-name) url))
-	  (with-current-buffer gnus-summary-buffer
-	    (gnus-summary-refer-article (shimbun-header-id header)))))))
+    (or (and (eq 'nnshimbun (car method))
+	     (nnshimbun-possibly-change-group nil (nth 1 method))
+	     (setq header (nnshimbun-search-xref
+			   (gnus-group-short-name gnus-newsgroup-name) url))
+	     (with-current-buffer gnus-summary-buffer
+	       (gnus-summary-refer-article (shimbun-header-id header))))
+	'w3m-goto-url)))
 
 (defun nnshimbun-setup-article-mode ()
   (set (make-local-variable 'w3m-goto-article-function)