diff options
| author | Kenjiro NAKAYAMA | 2014-01-05 10:27:26 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2014-01-05 10:27:26 +0100 |
| commit | 189340f5dc6570de29e645dafbc40744d8f3068e (patch) | |
| tree | 79f7432f2210fbfcc3c2b2c416a482c9469b7e5b | |
| parent | f4018140ec4bd45e88f9a8848ccae9d1db2260e2 (diff) | |
| download | emacs-189340f5dc6570de29e645dafbc40744d8f3068e.tar.gz emacs-189340f5dc6570de29e645dafbc40744d8f3068e.zip | |
Make the eww history browsing work again
* net/eww.el (eww-list-histories,eww-history-browse): Fixup.
(eww-history-quit): Delete and use quit-window.
(eww-history-kill): Delete, because it doesn't work well and
not necessary.
(eww-history-mode-map): Delete some keys and add easy-menu.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/net/eww.el | 90 |
2 files changed, 42 insertions, 55 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 343b225c029..8ea2498c246 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,6 +1,11 @@ | |||
| 1 | 2014-01-05 Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com> | 1 | 2014-01-05 Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com> |
| 2 | 2 | ||
| 3 | * net/eww.el (eww): Support single/double quote for search. | 3 | * net/eww.el (eww): Support single/double quote for search. |
| 4 | * net/eww.el (eww-list-histories,eww-history-browse): Fixup. | ||
| 5 | (eww-history-quit): Delete and use quit-window. | ||
| 6 | (eww-history-kill): Delete, because it doesn't work well and | ||
| 7 | not necessary. | ||
| 8 | (eww-history-mode-map): Delete some keys and add easy-menu. | ||
| 4 | 9 | ||
| 5 | 2014-01-05 Paul Eggert <eggert@cs.ucla.edu> | 10 | 2014-01-05 Paul Eggert <eggert@cs.ucla.edu> |
| 6 | 11 | ||
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index fdd9982ff57..38726fd7dcc 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -1283,32 +1283,30 @@ Differences in #targets are ignored." | |||
| 1283 | (interactive) | 1283 | (interactive) |
| 1284 | (when (null eww-history) | 1284 | (when (null eww-history) |
| 1285 | (error "No eww-histories are defined")) | 1285 | (error "No eww-histories are defined")) |
| 1286 | (set-buffer (get-buffer-create "*eww history*")) | 1286 | (let ((eww-history-trans eww-history)) |
| 1287 | (eww-history-mode) | 1287 | (set-buffer (get-buffer-create "*eww history*")) |
| 1288 | (let ((inhibit-read-only t) | 1288 | (eww-history-mode) |
| 1289 | (domain-length 0) | 1289 | (let ((inhibit-read-only t) |
| 1290 | (title-length 0) | 1290 | (domain-length 0) |
| 1291 | url title format start) | 1291 | (title-length 0) |
| 1292 | (erase-buffer) | 1292 | url title format start) |
| 1293 | (dolist (history eww-history) | 1293 | (erase-buffer) |
| 1294 | (setq start (point)) | 1294 | (dolist (history eww-history-trans) |
| 1295 | (setq domain-length (max domain-length (length (plist-get history :url)))) | 1295 | (setq start (point)) |
| 1296 | (setq title-length (max title-length (length (plist-get history :title)))) | 1296 | (setq domain-length (max domain-length (length (plist-get history :url)))) |
| 1297 | ) | 1297 | (setq title-length (max title-length (length (plist-get history :title))))) |
| 1298 | (setq format (format "%%-%ds %%-%ds" title-length domain-length) | 1298 | (setq format (format "%%-%ds %%-%ds" title-length domain-length) |
| 1299 | header-line-format | 1299 | header-line-format |
| 1300 | (concat " " (format format "Title" "URL"))) | 1300 | (concat " " (format format "Title" "URL"))) |
| 1301 | 1301 | (dolist (history eww-history-trans) | |
| 1302 | (dolist (history eww-history) | 1302 | (setq start (point)) |
| 1303 | (setq url (plist-get history :url)) | 1303 | (setq url (plist-get history :url)) |
| 1304 | (setq title (plist-get history :title)) | 1304 | (setq title (plist-get history :title)) |
| 1305 | (insert (format format title url)) | 1305 | (insert (format format title url)) |
| 1306 | (insert "\n") | 1306 | (insert "\n") |
| 1307 | (put-text-property start (point) 'eww-history history) | 1307 | (put-text-property start (1+ start) 'eww-history history)) |
| 1308 | ) | 1308 | (goto-char (point-min))) |
| 1309 | (goto-char (point-min))) | 1309 | (pop-to-buffer "*eww history*"))) |
| 1310 | (pop-to-buffer "*eww history*") | ||
| 1311 | ) | ||
| 1312 | 1310 | ||
| 1313 | (defun eww-history-browse () | 1311 | (defun eww-history-browse () |
| 1314 | "Browse the history under point in eww." | 1312 | "Browse the history under point in eww." |
| @@ -1316,39 +1314,23 @@ Differences in #targets are ignored." | |||
| 1316 | (let ((history (get-text-property (line-beginning-position) 'eww-history))) | 1314 | (let ((history (get-text-property (line-beginning-position) 'eww-history))) |
| 1317 | (unless history | 1315 | (unless history |
| 1318 | (error "No history on the current line")) | 1316 | (error "No history on the current line")) |
| 1319 | (eww-history-quit) | 1317 | (quit-window) |
| 1320 | (pop-to-buffer "*eww*") | 1318 | (eww-restore-history history))) |
| 1321 | (eww-browse-url (plist-get history :url)))) | ||
| 1322 | |||
| 1323 | (defun eww-history-quit () | ||
| 1324 | "Kill the current buffer." | ||
| 1325 | (interactive) | ||
| 1326 | (kill-buffer (current-buffer))) | ||
| 1327 | |||
| 1328 | (defvar eww-history-kill-ring nil) | ||
| 1329 | |||
| 1330 | (defun eww-history-kill () | ||
| 1331 | "Kill the current history." | ||
| 1332 | (interactive) | ||
| 1333 | (let* ((start (line-beginning-position)) | ||
| 1334 | (history (get-text-property start 'eww-history)) | ||
| 1335 | (inhibit-read-only t)) | ||
| 1336 | (unless history | ||
| 1337 | (error "No history on the current line")) | ||
| 1338 | (forward-line 1) | ||
| 1339 | (push (buffer-substring start (point)) eww-history-kill-ring) | ||
| 1340 | (delete-region start (point)) | ||
| 1341 | (setq eww-history (delq history eww-history)) | ||
| 1342 | )) | ||
| 1343 | 1319 | ||
| 1344 | (defvar eww-history-mode-map | 1320 | (defvar eww-history-mode-map |
| 1345 | (let ((map (make-sparse-keymap))) | 1321 | (let ((map (make-sparse-keymap))) |
| 1346 | (suppress-keymap map) | 1322 | (suppress-keymap map) |
| 1347 | (define-key map "q" 'eww-history-quit) | 1323 | (define-key map "q" 'quit-window) |
| 1348 | (define-key map [(control k)] 'eww-history-kill) | ||
| 1349 | (define-key map "\r" 'eww-history-browse) | 1324 | (define-key map "\r" 'eww-history-browse) |
| 1350 | (define-key map "n" 'next-error-no-select) | 1325 | ;; (define-key map "n" 'next-error-no-select) |
| 1351 | (define-key map "p" 'previous-error-no-select) | 1326 | ;; (define-key map "p" 'previous-error-no-select) |
| 1327 | |||
| 1328 | (easy-menu-define nil map | ||
| 1329 | "Menu for `eww-history-mode-map'." | ||
| 1330 | '("Eww History" | ||
| 1331 | ["Exit" quit-window t] | ||
| 1332 | ["Browse" eww-history-browse | ||
| 1333 | :active (get-text-property (line-beginning-position) 'eww-history)])) | ||
| 1352 | map)) | 1334 | map)) |
| 1353 | 1335 | ||
| 1354 | (define-derived-mode eww-history-mode nil "eww history" | 1336 | (define-derived-mode eww-history-mode nil "eww history" |