nixos/pkgsets/emacs/transmission.nix

51 lines
1.7 KiB
Nix
Raw Normal View History

2023-09-11 20:23:04 +02:00
{
config,
lib,
pkgs,
...
}:
2019-12-18 09:48:37 +01:00
with lib;
2023-09-11 20:23:04 +02:00
mkIf (elem "emacs::transmission" config.machine.pkgs) {
programs.emacs.init.usePackage = {
transmission = {
enable = true;
defer = true;
command = ["transmission"];
bindLocal = {
transmission-mode-map = {
"A" = '' (lambda ()
(interactive)
(transmission-add (read-string "Magnet URI: ")))'';
};
2019-12-18 09:48:37 +01:00
};
2023-09-11 20:23:04 +02:00
config = ''
;; Auto refresh for all transmission buffers
(setq transmission-refresh-modes '(transmission-mode
transmission-files-mode
transmission-info-mode
transmission-peers-mode))
2019-12-18 09:48:37 +01:00
2023-09-11 20:23:04 +02:00
(defun transmission ()
"Open a `transmission-mode' buffer."
(interactive)
(let* ((name "*transmission*")
(buffer (or (get-buffer name)
(generate-new-buffer name))))
(transmission-turtle-poll)
(unless (eq buffer (current-buffer))
(with-current-buffer buffer
(unless (eq major-mode 'transmission-mode)
(condition-case e
(progn
(transmission-mode)
(revert-buffer)
(goto-char (point-min)))
(error
(kill-buffer buffer)
(signal (car e) (cdr e))))))
(switch-to-buffer buffer))))
'';
};
2019-12-18 09:48:37 +01:00
};
2023-09-11 20:23:04 +02:00
}