[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e0c19e8: Trim titles in eww so that the host from the URL is visi
From: |
Lars Ingebrigtsen |
Subject: |
master e0c19e8: Trim titles in eww so that the host from the URL is visible |
Date: |
Tue, 18 Aug 2020 06:31:31 -0400 (EDT) |
branch: master
commit e0c19e8dced9cc0149dc64a7494988bbfe765846
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Trim titles in eww so that the host from the URL is visible
* lisp/net/eww.el (eww-update-header-line-format): Trim the line
of the title so that the host bit of the URL is visible (bug#42898).
---
lisp/net/eww.el | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index e7170b3..04deb5b 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -672,9 +672,30 @@ Currently this means either text/html or
application/xhtml+xml."
(setq header-line-format
(and eww-header-line-format
(let ((title (plist-get eww-data :title))
- (peer (plist-get eww-data :peer)))
+ (peer (plist-get eww-data :peer))
+ (url (plist-get eww-data :url)))
(when (zerop (length title))
(setq title "[untitled]"))
+ ;; Limit the length of the title so that the host name
+ ;; of the URL is always visible.
+ (when url
+ (let* ((parsed (url-generic-parse-url url))
+ (host-length (length (format "%s://%s"
+ (url-type parsed)
+ (url-host parsed))))
+ (width (window-width)))
+ (cond
+ ;; The host bit is wider than the window, so nix
+ ;; the title.
+ ((> (+ host-length 5) width)
+ (setq title ""))
+ ;; Trim the title.
+ ((> (+ (length title) host-length 2) width)
+ (setq title (concat
+ (substring title 0 (- width
+ host-length
+ 5))
+ "..."))))))
;; This connection has is https.
(when peer
(setq title
@@ -686,7 +707,7 @@ Currently this means either text/html or
application/xhtml+xml."
"%" "%%"
(format-spec
eww-header-line-format
- `((?u . ,(or (plist-get eww-data :url) ""))
+ `((?u . ,(or url ""))
(?t . ,title))))))))
(defun eww-tag-title (dom)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master e0c19e8: Trim titles in eww so that the host from the URL is visible,
Lars Ingebrigtsen <=