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

Adding a URL to antenna



大和です。

リリース直前のようですが、ほんの少しだけ便利な機能(のプロトタイプ;)
を書いてみたのでここに投稿します。次の開発バージョンにでも含めて
頂けたら幸いです。

現在w3mで閲覧中のページをantennaの検査対象にする操作を簡略化しました。
現状では、ページを追加するために閲覧中のページのURLを
w3m-print-current-urlなりで記憶して、
M-x customize-variable w3m-antenna-sites C-y
するかあるいは、
C-x C-f .emacs C-y
する必要がありました。添付したパッチを用いると "+"キーを押すだけで、

M-x customize-variable w3m-antenna-sites C-y

が連続して実行されます。

bookmarkを追加するようにantennaを追加できるようにしたいのですが、
そこまで綺麗にまとめることができませんでした。
本当はantennaとbookmarkを統合できると良いのですが.

2001-11-02  Masatake YAMATO  <jet@gyve.org>

	* w3m.el (autoload): Added w3m-antenna-add-current-url.
	(w3m-lynx-like-map): Likewise.
	(w3m-info-like-map): Likewise.
	(w3m-mode): Added w3m-antenna-add-current-url to doc string.

	* w3m-antenna.el (string-with-default): New widget.
	(string-with-default-value-create): New function.
	(w3m-antenna-sites): Use string-with-default widgets
	instead of string widgets.
	(w3m-antenna-tmp-url): New variable.
	(w3m-antenna-tmp-title): New variable.
	(w3m-antenna-add-current-url): New function.
	(w3m-antenna-add): New function.

Index: w3m-antenna.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-antenna.el,v
retrieving revision 1.22
diff -u -r1.22 w3m-antenna.el
--- w3m-antenna.el	2001/10/23 02:47:43	1.22
+++ w3m-antenna.el	2001/11/03 11:24:45
@@ -50,14 +50,36 @@
   :group 'w3m
   :prefix "w3m-antenna-")
 
+(define-widget 'string-with-default 'string
+  "String widget with default value.
+When creating a new widget, its value is given by an expression specified
+with :default-value-from."
+  :tag "URL"
+  :value-from nil
+  :create 'string-with-default-value-create)
+
+(defun string-with-default-value-create (widget)
+  (if (string= "" (widget-get widget :value))
+      ;; No value is given.
+      (widget-put widget :value
+		  (let* ((symbol (widget-get widget :value-from))
+			 (value  (eval symbol)))
+		    (if value
+			(set symbol nil)
+		      (setq value ""))
+		    value)))
+  (widget-default-create widget))
+
 (defcustom w3m-antenna-sites
   nil
   "List of WEB sites, watched by `w3m-antenna'."
   :group 'w3m-antenna
   :type '(repeat
 	  (list
-	   (string :tag "URL")
-	   (string :tag "Title")
+	   (string-with-default :tag "URL" 
+				:value-from w3m-antenna-tmp-url)
+	   (string-with-default :tag "Title" 
+				:value-from w3m-antenna-tmp-title)
 	   (choice :tag "Class"
 		   (const :tag "Normal" nil)
 		   (const :tag "Modified Time" time)
@@ -325,6 +347,26 @@
   (interactive "P")
   (w3m-goto-url "about://antenna/" no-cache))
 
+(defvar w3m-antenna-tmp-url nil)
+(defvar w3m-antenna-tmp-title nil)
+(defun w3m-antenna-add-current-url (&optional arg)
+  "Add link of current page to antenna.
+With prefix, ask new url to add instead of current page."
+  (interactive "P")
+  (w3m-antenna-add (if arg (w3m-input-url) w3m-current-url)
+		   w3m-current-title))
+(defun w3m-antenna-add (url &optional title)
+  "Add URL to antenna.
+Optional argument TITLE is title of link."
+  (setq w3m-antenna-tmp-url url)
+  (setq w3m-antenna-tmp-title title)
+  (customize-variable 'w3m-antenna-sites)
+  ;; dirty...
+  (re-search-forward "INS")
+  (backward-char 1)
+  (widget-button-press (point))
+  (re-search-forward "State:")
+  (backward-char 2))
 
 (provide 'w3m-antenna)
 ;;; w3m-antenna.el ends here.

Index: w3m.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.474
diff -u -r1.474 w3m.el
--- w3m.el	2001/11/02 15:26:17	1.474
+++ w3m.el	2001/11/03 11:25:06
@@ -106,6 +106,8 @@
   (autoload 'w3m-about-weather "w3m-weather")
   (autoload 'w3m-antenna "w3m-antenna"
     "Display antenna report." t)
+  (autoload 'w3m-antenna-add-current-url "w3m-antenna"
+    "Add link of current page to antenna." t)
   (autoload 'w3m-about-antenna "w3m-antenna")
   (autoload 'w3m-dtree "w3m-dtree"
     "Display directory tree." t)
@@ -3725,6 +3727,7 @@
     (define-key map "?" 'describe-mode)
     (define-key map "\M-a" 'w3m-bookmark-add-this-url)
     (define-key map "a" 'w3m-bookmark-add-current-url)
+    (define-key map "+" 'w3m-antenna-add-current-url)
     (define-key map "H" 'w3m-gohome)
     (define-key map "A" 'w3m-antenna)
     (define-key map "W" 'w3m-weather)
@@ -3770,6 +3773,7 @@
     (define-key map " " 'w3m-scroll-up-or-next-url)
     (define-key map "a" 'w3m-bookmark-add-current-url)
     (define-key map "\M-a" 'w3m-bookmark-add-this-url)
+    (define-key map "+" 'w3m-antenna-add-current-url)
     (define-key map "A" 'w3m-antenna)
     (define-key map "b" 'w3m-scroll-down-or-previous-url)
     (define-key map "c" 'w3m-print-this-url)
@@ -3946,6 +3950,7 @@
 	If called with '\\[universal-argument]', this command displays arrived-DB history.
 \\[w3m-antenna]	Display the report change of WEB sites.
 	If called with '\\[universal-argument]', this command reloads report.
+\\[w3m-antenna-add-this-url]	Add link under cursor to antenna.
 \\[w3m-search]	Search query.
 	If called with '\\[universal-argument]', you can choose search engine.
 \\[w3m-weather]	Display weather report.