From 5e22faec85a4073e7112f4388ce5ae313882ba73 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 17 Sep 2020 16:57:21 +0100 Subject: fix(notable): Truncate first lines if they don't fit the window Change-Id: I00746aa285d7854b8e35b6d00aa7c608ccf8ce77 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1988 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tools/emacs-pkgs/notable/notable.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tools/emacs-pkgs/notable/notable.el') diff --git a/tools/emacs-pkgs/notable/notable.el b/tools/emacs-pkgs/notable/notable.el index ba59a1ee2b..4668dd333c 100644 --- a/tools/emacs-pkgs/notable/notable.el +++ b/tools/emacs-pkgs/notable/notable.el @@ -204,10 +204,14 @@ (check-type id integer) (check-type note notable--note) - (let ((start (point)) - (first-line (car (s-lines (notable--note-content note)))) - (date (dottime-format (seconds-to-time - (notable--note-time note))))) + (let* ((start (point)) + (date (dottime-format (seconds-to-time + (notable--note-time note)))) + (first-line (truncate-string-to-width + (car (s-lines (notable--note-content note))) + ;; Length of the window, minus the date prefix: + (- (window-width) (+ 2 (length date))) + nil nil 1))) (insert (propertize (s-concat date " " first-line) 'notable-note-id id)) (insert "\n"))) -- cgit 1.4.1