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

Re: bridging between emacs's bookmark.el and emacs-w3m



Thierry Volpiatto <thierry.volpiatto@xxxxxxxxx> writes:

> Masatake YAMATO <yamato@xxxxxxxxxx> writes:
>
>>> In [emacs-w3m : No.11385] 大和さん wrote:
>>>> 今日bzrからとってきたソースコードでビルドしたemacsで試してみましたが、
>>>> 期待通り動作しました。
>>> 
>>> どうもありがとうございます。少しモディファイして emacs-w3m に組
>>> み込みました。ユーザーは何もしなくても Emacs 23 以上で有効です。
>>> 
>>> 主な変更内容:
>>> ・w3m-load.el に bookmark-w3m-bookmark-jump の autoload を追加。
>>> ・bookmark-w3m.el が作った bookmark を、emacs-w3m が load されて
>>>  いないときでも使えるようにするためには (require 'w3m-load) が
>>>   必要であることをコメントに追加。
>>> ・コンパイル警告を黙らせrるためのおまじないを追加。
>>>
>>> こんなかんじでいかがでしょう?
>>
>> お手数をおかけしました。ありがとうございます。
>>
>> ということで私の個人のツリーでの作業を停止します。
>> http://github.com/masatake/bookmark-w3m-el/blob/master/README
>>
>> 大和
>>
>>
>
> I don't understand all this, so if what follow is not related ignore.
> You will find emacs-w3m handlers for bookmark.el in bookmark-extensions.el.
> http://mercurial.intuxication.org/hg/emacs-bookmark-extension/

I had a look at bookmark-w3m.el, it is incomplete, here is code related
to that from bookmark-extensions.el, if it can help:

,----
| ;;; W3M support
| (defun bmkext-make-w3m-record ()
|   "Make a special entry for w3m buffers."
|   (require 'w3m)                        ; For `w3m-current-url'.
|   `(,w3m-current-title
|     ,@(bookmark-make-record-default 'no-file)
|       (filename . ,w3m-current-url)
|       (handler . bmkext-jump-w3m)))
| 
| (add-hook 'w3m-mode-hook
|           #'(lambda ()
|               (set (make-local-variable 'bookmark-make-record-function)
|                    'bmkext-make-w3m-record)))
| 
| (defun bmkext-w3m-set-new-buffer-name ()
|   "Set the w3m buffer name according to the number of w3m buffers already open."
|   (let ((len  (length (w3m-list-buffers 'nosort))))
|     (if (eq len 0)  "*w3m*"  (format "*w3m*<%d>" (1+ len)))))
| 
| (defun bmkext-jump-w3m-new-session (bookmark)
|   "Jump to W3m bookmark BOOKMARK, setting a new tab."
|   (let ((file  (bookmark-prop-get bookmark 'filename))
|         (buf   (bmkext-w3m-set-new-buffer-name)))
|     (w3m-browse-url file 'newsession)
|     (while (not (get-buffer buf)) (sit-for 1)) ; Be sure we have the W3m buffer.
|     (with-current-buffer buf
|       (goto-char (point-min))
|       ;; Wait until data arrives in buffer, before setting region.
|       (while (eq (line-beginning-position) (line-end-position)) (sit-for 1)))
|     (bookmark-default-handler
|      `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))
| 
| (defun bmkext-jump-w3m-only-one-tab (bookmark)
|   "Close all W3m sessions and jump to BOOKMARK in a new W3m buffer."
|   (let ((file  (bookmark-prop-get bookmark 'filename)))
|     (w3m-quit 'force)                   ; Be sure we start with an empty W3m buffer.
|     (w3m-browse-url file)
|     (with-current-buffer "*w3m*" (while (eq (point-min) (point-max)) (sit-for 1)))
|     (bookmark-default-handler
|      `("" (buffer . ,(buffer-name (current-buffer))) .
|           ,(bookmark-get-bookmark-record bookmark)))))
| 
| (defun bmkext-jump-w3m (bookmark)
|   "Handler function for record returned by `bmkext-make-w3m-record'.
| BOOKMARK is a bookmark name or a bookmark record.
| Use multi-tabs in W3m if `bmkext-w3m-allow-multi-tabs' is non-nil.
| If a prefix arg is given, open an external navigator defined in
| `bmkext-external-browse-url-function'."
|   (if (and current-prefix-arg bmkext-external-browse-url-function)
|       (bmkext-jump-url-external bookmark)
|       (if bmkext-w3m-allow-multi-tabs
|           (bmkext-jump-w3m-new-session bookmark)
|           (bmkext-jump-w3m-only-one-tab bookmark))))
| 
| (defun bmkext-jump-url-external (bookmark)
|   "Jump to BOOKMARK in an external navigator.
| External navigator is defined by `bmkext-external-browse-url-function'."
|   (let ((file  (bookmark-prop-get bookmark 'filename)))
|     (bmkext-update-time-and-increment-visits bookmark 'batch)
|     (funcall bmkext-external-browse-url-function file)))
`----

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997