about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-09-17T15·57+0100
committertazjin <mail@tazj.in>2020-09-18T23·32+0000
commit5e22faec85a4073e7112f4388ce5ae313882ba73 (patch)
tree1d5ec9670ecf7f42a3270dab80fe6ca51c0c01b6 /tools
parent30066b4ba0fbde562219ea1d977cdf1f08a69baa (diff)
fix(notable): Truncate first lines if they don't fit the window r/1804
Change-Id: I00746aa285d7854b8e35b6d00aa7c608ccf8ce77
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1988
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs-pkgs/notable/notable.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/emacs-pkgs/notable/notable.el b/tools/emacs-pkgs/notable/notable.el
index ba59a1ee2b22..4668dd333c99 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")))