From 2c3d1113927f19903a4909f010c9fe2a73a8f741 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Sun, 7 Dec 2014 20:32:07 +0100 Subject: [PATCH] eww bookmark display fixup Fixes: debbugs:16398 * net/eww.el (eww-bookmark-prepare): Display URLs in first by displaying shortened titles first. --- lisp/ChangeLog | 5 +++++ lisp/net/eww.el | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 50df1cd3253..287352cdb0d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-12-07 Lars Magne Ingebrigtsen + + * net/eww.el (eww-bookmark-prepare): Display URLs in first by + displaying shortened titles first (bug#16398). + 2014-12-07 Tom Willemse (tiny change) * progmodes/python.el: Recognize docstrings. diff --git a/lisp/net/eww.el b/lisp/net/eww.el index e88afb50326..c1ba4294905 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1440,19 +1440,18 @@ Differences in #targets are ignored." (user-error "No bookmarks are defined")) (set-buffer (get-buffer-create "*eww bookmarks*")) (eww-bookmark-mode) - (let ((format "%-40s %s") - (inhibit-read-only t) - start url) + (let* ((width (/ (window-width) 2)) + (format (format "%%-%ds %%s" width)) + (inhibit-read-only t) + start title) (erase-buffer) - (setq header-line-format (concat " " (format format "URL" "Title"))) + (setq header-line-format (concat " " (format format "Title" "URL"))) (dolist (bookmark eww-bookmarks) - (setq start (point)) - (setq url (plist-get bookmark :url)) - (when (> (length url) 40) - (setq url (substring url 0 40))) - (insert (format format url - (plist-get bookmark :title)) - "\n") + (setq start (point) + title (plist-get bookmark :title)) + (when (> (length title) width) + (setq title (substring title 0 width))) + (insert (format format title (plist-get bookmark :url)) "\n") (put-text-property start (1+ start) 'eww-bookmark bookmark)) (goto-char (point-min)))) -- 2.39.2