From d9aecce780a90de5d0a469d016ea592d35ab660f Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sat, 30 Aug 2025 22:18:47 +0800 Subject: [PATCH] feat(doom): Enhance telega clipboard and enable lisp This commit introduces significant improvements to clipboard handling within the Telega (Telegram) client and enables the LSP module. ### Telega Clipboard Enhancements - Paste Images: Overrides the default image pasting function (`telega-chatbuf-attach-clipboard`) with more image format support. - Copy Images: Adds a new interactive command, `+telega-save-file-to-clipboard`, to download a file from a message and copy it directly to the Wayland clipboard via `wl-copy`. ### LSP Support - Enabled the `:tools lsp` module to activate Language Server Protocol support for improved code intelligence. --- .../modules/programs/doom/config/config.el | 38 +++++++++++++++++++ .../modules/programs/doom/config/init.el | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/home/david/modules/programs/doom/config/config.el b/home/david/modules/programs/doom/config/config.el index fd993f6..94ea667 100644 --- a/home/david/modules/programs/doom/config/config.el +++ b/home/david/modules/programs/doom/config/config.el @@ -41,3 +41,41 @@ (setq exec-path (append exec-path my/emacs-deps-exec-path)))) + +(advice-add #'telega-chatbuf-attach-clipboard + :override #'(lambda (doc-p) + (interactive "P") + (let* ((selection-coding-system 'no-conversion) ;for rawdata + (temporary-file-directory telega-temp-dir) + (tmpfile (telega-temp-name "clipboard" ".png")) + (coding-system-for-write 'binary)) + (if (eq system-type 'darwin) + (progn + ;; NOTE: On MacOS, try extracting clipboard using pngpaste + (unless (executable-find "pngpaste") + (error "Please install pngpaste to paste images")) + (unless (= 0 (telega-screenshot-with-pngpaste tmpfile)) + (error "No image in CLIPBOARD"))) + (let ((image-data (or (gui-get-selection 'CLIPBOARD 'image/png) + (gui-get-selection 'CLIPBOARD 'image/jpeg) + (error "No image in CLIPBOARD")))) + (write-region image-data nil tmpfile nil 'quiet))) + (telega-chatbuf-attach-media tmpfile (when doc-p 'preview))))) + +(defun +telega-save-file-to-clipboard (msg) + "Save file at point to clipboard. +NOTE: wayland only." + (interactive (list (telega-msg-for-interactive))) + (let ((file (telega-msg--content-file msg))) + (unless file + (user-error "No file associated with message")) + (telega-file--download file + :priority 32 + :update-callback + (lambda (dfile) + (telega-msg-redisplay msg) + (message "Wait for downloading to finish…") + (when (telega-file--downloaded-p dfile) + (let* ((fpath (telega--tl-get dfile :local :path))) + (shell-command (format "wl-copy < \"%s\"" fpath)) + (message (format "File saved to clipboard: %s" fpath)))))))) diff --git a/home/david/modules/programs/doom/config/init.el b/home/david/modules/programs/doom/config/init.el index 8c33682..e8f3dec 100644 --- a/home/david/modules/programs/doom/config/init.el +++ b/home/david/modules/programs/doom/config/init.el @@ -100,7 +100,7 @@ (eval +overlay) ; run code, run (also, repls) lookup ; navigate your code and its documentation ;;llm ; when I said you needed friends, I didn't mean... - ;;lsp ; M-x vscode + lsp ; M-x vscode magit ; a git porcelain for Emacs make ; run make tasks from Emacs ;;pass ; password manager for nerds