-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelm-webkit.el
138 lines (119 loc) · 3.81 KB
/
helm-webkit.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
;;; helm-webkit.el --- Search browse history of emacs-webkit
;; Filename: helm-webkit.el
;; Description: Search browse history of emacs-webkit
;; Author: Andy Stewart <[email protected]>
;; Maintainer: Andy Stewart <[email protected]>
;; Copyright (C) 2014, Andy Stewart, all rights reserved.
;; Created: 2014-06-13 03:30:03
;; Version: 0.1
;; Last-Updated: 2014-06-13 03:30:03
;; By: Andy Stewart
;; URL: http://www.emacswiki.org/emacs/download/helm-webkit.el
;; Keywords: webkit
;; Compatibility: GNU Emacs 24.4.50.1
;;
;; Features that might be required by this library:
;;
;; `webkit'
;;
;;; This file is NOT part of GNU Emacs
;;; License
;;
;; This program 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, or (at your option)
;; any later version.
;; This program 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 this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; `helm-webkit' is extension to search browse history of emacs-webkit.
;;
;;; Installation:
;;
;; You need install emacs-webkit first: http://www.emacswiki.org/emacs/WebKit
;;
;; Put helm-webkit.el to your load-path.
;; The load-path is usually ~/elisp/.
;; It's set in your ~/.emacs like this:
;; (add-to-list 'load-path (expand-file-name "~/elisp"))
;;
;; And the following to your ~/.emacs startup file.
;;
;; (require 'helm-webkit)
;;
;; No need more.
;;; Customize:
;;
;;
;;
;; All of the above can customize by:
;; M-x customize-group RET helm-webkit RET
;;
;;; Change log:
;;
;; 2014/06/13
;; * First released.
;;
;;; Acknowledgements:
;;
;;
;;
;;; TODO
;;
;;
;;
;;; Require
(require 'webkit)
;;; Code:
(defun hash-to-list (hashtable)
"Return a list that represent the hashtable."
(let (hashlist)
(maphash (lambda (kk vv) (setq hashlist (cons (list kk vv) hashlist))) hashtable)
hashlist))
(defvar helm-source-webkit-buffer "*helm webkit browse history*")
(defvar helm-source-webkit
`((name . "Web Browser")
(candidate-number-limit . 9999)
(candidates
. (lambda nil
(loop for url-info in (mapcar (lambda (a) (list (car a) (cadadr a))) (sort (hash-to-list webkit-history-urls) (lambda (a b) (> (caadr a) (caadr b)))))
for name = (car url-info)
for title = (cdr url-info)
collect
(cons
(concat
(propertize (format "%s" name)
'face 'font-lock-function-name-face)
(propertize (format " %s" title)
'face 'font-lock-doc-face))
(list name title)))
))
(action . (("Open URL" .
(lambda (candidate)
(webkit-open-url (car candidate))
))
("Delete history" .
(lambda (candidate)
(webkit-delete-history-url (car candidate))))
("Clean all history" .
(lambda (candidate)
(webkit-clean-history)))
("Toggle console info"
((webkit-toggle-console-info)))
))
(persistent-action . describe-command)))
;;;###webkit
(defun helm-webkit-commands nil
"Select from webkit commands to execute."
(interactive)
(helm :sources 'helm-source-webkit
:buffer helm-source-webkit-buffer))
(provide 'helm-webkit)
;;; helm-webkit.el ends here