From de7d377e422454043866d0fe513e988d025d2711 Mon Sep 17 00:00:00 2001 From: "Wayne H. Shephard" Date: Sat, 21 Nov 2026 22:55:03 +0300 Subject: [PATCH] added missing file (desynced with dev env on debian) --- lisp/mattermost-files.el | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lisp/mattermost-files.el diff --git a/lisp/mattermost-files.el b/lisp/mattermost-files.el new file mode 100644 index 0000000..312ad75 --- /dev/null +++ b/lisp/mattermost-files.el @@ -0,0 +1,30 @@ +;;; mattermost-files.el --- File attachment helpers -*- lexical-binding: t; -*- + +(require 'mattermost-custom) +(require 'mattermost-protocol) + +(defun mattermost--format-file-size (bytes) + "Format BYTES as human-readable size." + (cond + ((< bytes 1024) (format "%d B" bytes)) + ((< bytes (* 1024 1024)) (format "%.1f KB" (/ bytes 1024.0))) + ((< bytes (* 1024 1024 1024)) (format "%.1f MB" (/ bytes (* 1024.0 1024.0)))) + (t (format "%.1f GB" (/ bytes (* 1024.0 1024.0 1024.0)))))) + +(defun mattermost--format-file-block (files) + "Return a propertized multi-line string describing FILES plist list." + (mapconcat + (lambda (f) + (let* ((name (or (plist-get f :name) "unknown")) + (size (or (plist-get f :size) 0)) + (id (plist-get f :id))) + (propertize + (format " 📎 %s (%s)\n" name (mattermost--format-file-size size)) + 'mm-file-id id + 'mm-file-name name + 'mouse-face 'highlight + 'help-echo "RET to download and open"))) + files + "")) + +(provide 'mattermost-files)