forked from emacs-w3m/emacs-w3m
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookmark-w3m.el
86 lines (69 loc) · 3.06 KB
/
bookmark-w3m.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
;;; bookmark-w3m.el --- bridging between emacs's bookmark.el and emacs-w3m
;; Copyright (C) 2010, 2019 Masatake YAMATO
;;
;; Author: Masatake YAMATO <[email protected]>
;;
;;; Commentary:
;; From version 23.1 bookmark.el of GNU emacs supports the mode own
;; bookmark mechanism. This is w3m.el side adapter to the mechanism.
;; This version of bookmark-w3m.el should work on Emacs 23 and greater.
;;
;; To enable the bookmark to work even when emacs-w3m is not loaded,
;; add the following snippet to the ~/.emacs file:
;;
;; (require 'w3m-load)
;;; About copyright:
;; Most of all codes are derived from man.el of GNU Emacs.
;; So the same license of man.el is applied to this software.
;; =========================================================================
;;; man.el --- browse UNIX manual pages -*- coding: iso-8859-1 -*-
;; Copyright (C) 1993, 1994, 1996, 1997, 2001, 2002, 2003, 2004, 2005,
;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Barry A. Warsaw <[email protected]>
;; Maintainer: FSF
;; Keywords: help
;; Adapted-By: ESR, pot
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
(defvar bookmark-make-record-function)
(defvar w3m-current-title)
(defvar w3m-current-url)
(declare-function bookmark-default-handler "bookmark" (bmk-record))
(declare-function bookmark-get-bookmark-record "bookmark" (bookmark))
(declare-function bookmark-make-record-default
"bookmark" (&optional no-file no-context posn))
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
(declare-function w3m-goto-url
"w3m" (url &optional reload charset post-data referer handler
element background))
(defun bookmark-w3m-bookmark-make-record ()
"Make a emacs bookmark entry for a w3m buffer."
`(,w3m-current-title
,@(bookmark-make-record-default 'no-file)
(filename . ,w3m-current-url)
(url . ,w3m-current-url)
(handler . bookmark-w3m-bookmark-jump)))
;;;###autoload
(defun bookmark-w3m-bookmark-jump (bookmark)
"Default bookmark handler for w3m buffers."
(let ((w3m-async-exec nil))
(w3m-goto-url (bookmark-prop-get bookmark 'url))
(let ((buf (current-buffer)))
(bookmark-default-handler
`("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark))))))
(defun bookmark-w3m-prepare ()
(interactive)
(set (make-local-variable 'bookmark-make-record-function)
'bookmark-w3m-bookmark-make-record))
(add-hook 'w3m-mode-hook 'bookmark-w3m-prepare)
(provide 'bookmark-w3m)
;; bookmark-w3m.el ends here