From 58f2b9a5583b998a94c40847fb8a7eba8474bcf6 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 24 Dec 2013 08:25:27 +0100 Subject: [PATCH] Fix eww bookmark window configuration * net/eww.el (eww-bookmark-quit): Remove. (eww-bookmark-browse): Restore the window configuration when you choose a bookmark. Fixes: debbugs:16144 --- lisp/ChangeLog | 6 ++++++ lisp/net/eww.el | 19 ++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 35920095e7a..79244ec160c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-12-24 Lars Ingebrigtsen + + * net/eww.el (eww-bookmark-quit): Remove. + (eww-bookmark-browse): Restore the window configuration when you + choose a bookmark (bug#16144). + 2013-12-24 Daniel Colascione * icomplete.el: Remove redundant :group arguments to `defcustom' diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 89a7eb9e050..b7f50c19321 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1083,6 +1083,8 @@ Differences in #targets are ignored." ;;; Bookmarks code (defvar eww-bookmarks nil) +(defvar eww-previous-window-configuration nil) +(make-variable-buffer-local 'eww-previous-window-configuration) (defun eww-add-bookmark () "Add the current page to the bookmarks." @@ -1127,6 +1129,7 @@ Differences in #targets are ignored." (unless eww-bookmarks (user-error "No bookmarks are defined")) (set-buffer (get-buffer-create "*eww bookmarks*")) + (setq eww-previous-window-configuration (current-window-configuration)) (eww-bookmark-mode) (let ((format "%-40s %s") (inhibit-read-only t) @@ -1178,21 +1181,15 @@ Differences in #targets are ignored." (cons bookmark (nthcdr line eww-bookmarks))))) (eww-write-bookmarks))) -(defun eww-bookmark-quit () - "Kill the current buffer." - (interactive) - (kill-buffer (current-buffer))) - (defun eww-bookmark-browse () "Browse the bookmark under point in eww." (interactive) (let ((bookmark (get-text-property (line-beginning-position) 'eww-bookmark))) (unless bookmark (user-error "No bookmark on the current line")) - ;; We wish to leave this window, but if it's the only window here, - ;; just let it remain. - (ignore-errors - (delete-window)) + (quit-window) + (when eww-previous-window-configuration + (set-window-configuration eww-previous-window-configuration)) (eww-browse-url (plist-get bookmark :url)))) (defun eww-next-bookmark () @@ -1238,7 +1235,7 @@ Differences in #targets are ignored." (defvar eww-bookmark-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map) - (define-key map "q" 'eww-bookmark-quit) + (define-key map "q" 'quit-window) (define-key map [(control k)] 'eww-bookmark-kill) (define-key map [(control y)] 'eww-bookmark-yank) (define-key map "\r" 'eww-bookmark-browse) @@ -1246,7 +1243,7 @@ Differences in #targets are ignored." (easy-menu-define nil map "Menu for `eww-bookmark-mode-map'." '("Eww Bookmark" - ["Exit" eww-bookmark-quit t] + ["Exit" quit-window t] ["Browse" eww-bookmark-browse :active (get-text-property (line-beginning-position) 'eww-bookmark)] ["Kill" eww-bookmark-kill -- 2.11.4.GIT