nixos/pkgs/doom-emacs/config/config.el

114 lines
4.9 KiB
EmacsLisp
Raw Normal View History

2025-08-25 14:12:57 +08:00
;;; config.el -*- lexical-binding: t; -*-
;;; Fix non-POSIX SHELL
(setq shell-file-name
(executable-find "bash"))
(let ((fish-exe (executable-find "fish")))
(setq-default vterm-shell
fish-exe)
(setq-default explicit-shell-file-name
fish-exe))
2025-08-25 14:12:57 +08:00
(setq doom-font (font-spec
:family "Maple Mono NF CN"
2025-07-13 06:04:55 +08:00
:size 20))
(setq doom-theme 'doom-gruvbox)
;;; Fix failure to loacate 'Symbols Nerd Font Mono' font
(setq nerd-icons-font-family "Maple Mono NF CN")
(setq telega-emoji-use-images
nil)
(map! :map global-map
"C-c t"
telega-prefix-map)
(setq display-line-numbers-type
'relative)
(add-hook 'telega-load-hook
'telega-notifications-mode)
(defvar my/emacs-deps-exec-path (seq-filter
(lambda (p)
(string-match-p
"/nix/store/.*-emacs-packages-deps/bin"
p))
exec-path))
(advice-add #'envrc--update
:after #'(lambda ()
(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))))))))
2025-09-17 00:25:17 +08:00
(map! :map global-map
"C-c n"
#'helm-nixos-options)
(with-eval-after-load 'evil
(scroll-on-jump-advice-add evil-redo)
(scroll-on-jump-advice-add evil-jump-item)
(scroll-on-jump-advice-add evil-jump-forward)
(scroll-on-jump-advice-add evil-jump-backward)
(scroll-on-jump-advice-add evil-ex-search-next)
(scroll-on-jump-advice-add evil-ex-search-previous)
(scroll-on-jump-advice-add evil-forward-paragraph)
(scroll-on-jump-advice-add evil-backward-paragraph)
(scroll-on-jump-advice-add evil-goto-mark)
;; Actions that themselves scroll.
(scroll-on-jump-with-scroll-advice-add evil-goto-line)
(scroll-on-jump-with-scroll-advice-add evil-goto-first-line)
(scroll-on-jump-with-scroll-advice-add evil-scroll-down)
(scroll-on-jump-with-scroll-advice-add evil-scroll-up)
(scroll-on-jump-with-scroll-advice-add evil-scroll-line-to-center)
(scroll-on-jump-with-scroll-advice-add evil-scroll-line-to-top)
(scroll-on-jump-with-scroll-advice-add evil-scroll-line-to-bottom)
(scroll-on-jump-with-scroll-advice-add evil-scroll-page-down)
(scroll-on-jump-with-scroll-advice-add evil-scroll-page-up))
(with-eval-after-load 'goto-chg
(scroll-on-jump-advice-add goto-last-change)
(scroll-on-jump-advice-add goto-last-change-reverse))
(global-set-key (kbd "<C-M-next>") (scroll-on-jump-interactive 'diff-hl-next-hunk))
(global-set-key (kbd "<C-M-prior>") (scroll-on-jump-interactive 'diff-hl-previous-hunk))