diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 4b15373..e00f449 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -267,7 +267,8 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." (general-define-key :keymaps 'evil-window-map - "x" 'kill-buffer-and-window) + "x" 'kill-buffer-and-window + "d" 'kill-current-buffer) (winner-mode 1) @@ -570,6 +571,9 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." "gt" 'my/treemacs-open-vterm "`" 'my/treemacs-open-vterm)) +;; (treemacs-define-custom-icon (concat " " (all-the-icons-fileicon "typescript")) "spec.ts") +;; (setq treemacs-file-extension-regex (rx "." (or "spec.ts" (+ (not "."))) eos)) + (use-package projectile :straight t :config @@ -658,7 +662,49 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." :straight t :if (not my/is-termux) :config - (advice-add 'wakatime-init :after (lambda () (setq wakatime-cli-path "/home/pavel/bin/wakatime"))) + (defun wakatime-client-command (savep) + "Return client command executable and arguments. + Set SAVEP to non-nil for write action." + (format "%s%s--entity \"%s\" --plugin \"%s/%s\" --time %.2f%s%s" + (if (s-blank wakatime-python-bin) "" (format "\"%s\" " wakatime-python-bin)) + (if (s-blank wakatime-cli-path) "wakatime " (format "\"%s\" " wakatime-cli-path)) + (buffer-file-name (current-buffer)) + wakatime-user-agent + wakatime-version + (float-time) + (if savep " --write" "") + (if (s-blank wakatime-api-key) "" (format " --key %s" wakatime-api-key)))) + (defun wakatime-call (savep) + "Call WakaTime command." + (let* + ((command (wakatime-client-command savep)) + (process-environment (if wakatime-python-path (cons (format "PYTHONPATH=%s" wakatime-python-path) process-environment) process-environment)) + (process + (start-process + "Shell" + (generate-new-buffer " *WakaTime messages*") + shell-file-name + shell-command-switch + command))) + + (set-process-sentinel process + `(lambda (process signal) + (when (memq (process-status process) '(exit signal)) + (kill-buffer (process-buffer process)) + (let ((exit-status (process-exit-status process))) + (when (and (not (= 0 exit-status)) (not (= 102 exit-status)) (not (= 1 exit-status))) + (when wakatime-disable-on-error + (wakatime-mode -1) + (global-wakatime-mode -1)) + (cond + ((= exit-status 103) (error "WakaTime Error (%s) Config file parse error. Check your ~/.wakatime.cfg file." exit-status)) + ((= exit-status 104) (error "WakaTime Error (%s) Invalid API Key. Set your api key with: (custom-set-variables '(wakatime-api-key \"XXXX\"))" exit-status)) + ((= exit-status 105) (error "WakaTime Error (%s) Unknown wakatime-cli error. Please check your ~/.wakatime.log file and open a new issue at https://github.com/wakatime/wakatime-mode" exit-status)) + ((= exit-status 106) (error "WakaTime Error (%s) Malformed heartbeat error. Please check your ~/.wakatime.log file and open a new issue at https://github.com/wakatime/wakatime-mode" exit-status)) + (t (message "WakaTime Error (%s) Make sure this command runs in a Terminal: %s" exit-status (wakatime-client-command nil))))))))) + (set-process-query-on-exit-flag process nil))) + (advice-add 'wakatime-init :after (lambda () (setq wakatime-cli-path "/home/pavel/bin/wakatime-cli"))) + ;; (setq wakatime-cli-path (executable-find "wakatime")) (global-wakatime-mode)) (use-package request @@ -3161,6 +3207,9 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." :init (my-leader-def "ai" #'erc-tls) :config + ;; Logging + (setq erc-log-channels-directory "~/.erc/logs") + (setq erc-save-buffer-on-part t) ;; Config of my ZNC instance. (setq erc-server "sqrtminusone.xyz") (setq erc-port 1984) @@ -3170,6 +3219,17 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." (setq erc-kill-buffer-on-part t) (setq erc-track-shorten-start 8)) +(setq erc-track-exclude-types '("NICK" "JOIN" "LEAVE" "QUIT" "PART" + "301" ; away notice + "305" ; return from awayness + "306" ; set awayness + "324" ; modes + "329" ; channel creation date + "332" ; topic notice + "333" ; who set the topic + "353" ; Names notice + )) + (use-package erc-hl-nicks :hook (erc-mode . erc-hl-nicks-mode) :after (erc) diff --git a/Emacs.org b/Emacs.org index 8e9fa4b..ccd2382 100644 --- a/Emacs.org +++ b/Emacs.org @@ -1,5 +1,5 @@ #+PROPERTY: header-args :mkdirp yes -#+PROPERTY: header-args:bash :tangle-mode (identity #o755) :comments link :shebang "#!/usr/bin/env bash" +#+PROPERTY: header-args:bash :tangle-mode (identity #o755) :comments link :shebang "#!/usr/bin/env bash" #+PROPERTY: header-args:emacs-lisp :tangle ~/.emacs.d/init.el :mkdirp yes #+TODO: CHECK(s) | OFF(o) @@ -693,7 +693,8 @@ Some keybindings I used in vim to switch buffers and can't let go of. (general-define-key :keymaps 'evil-window-map - "x" 'kill-buffer-and-window) + "x" 'kill-buffer-and-window + "d" 'kill-current-buffer) #+end_src And winner-mode to keep the history of window states. @@ -1153,6 +1154,11 @@ Function to open dired and vterm at given nodes. "gt" 'my/treemacs-open-vterm "`" 'my/treemacs-open-vterm)) #+end_src +*** Custom icons +#+begin_src emacs-lisp +;; (treemacs-define-custom-icon (concat " " (all-the-icons-fileicon "typescript")) "spec.ts") +;; (setq treemacs-file-extension-regex (rx "." (or "spec.ts" (+ (not "."))) eos)) +#+end_src ** Projectile [[https://github.com/bbatsov/projectile][Projectile]] gives a bunch of useful functions for managing projects, like finding files within a project, fuzzy-find, replace, etc. @@ -1291,14 +1297,67 @@ Before I figure out how to package this for Guix: - Run ~go build~ - Copy the binary to the =~/bin= folder -#+begin_src emacs-lisp +#+begin_src emacs-lisp :noweb yes (use-package wakatime-mode :straight t :if (not my/is-termux) :config - (advice-add 'wakatime-init :after (lambda () (setq wakatime-cli-path "/home/pavel/bin/wakatime"))) + <> + (advice-add 'wakatime-init :after (lambda () (setq wakatime-cli-path "/home/pavel/bin/wakatime-cli"))) + ;; (setq wakatime-cli-path (executable-find "wakatime")) (global-wakatime-mode)) #+end_src + +**** Fixes +wakatime-mode.el seems to be incompatible with the latest Go cli. The fix is to replace =--file= with =--entity=. + +#+begin_src emacs-lisp :tangle no :noweb-ref wakatime-fixes +(defun wakatime-client-command (savep) + "Return client command executable and arguments. + Set SAVEP to non-nil for write action." + (format "%s%s--entity \"%s\" --plugin \"%s/%s\" --time %.2f%s%s" + (if (s-blank wakatime-python-bin) "" (format "\"%s\" " wakatime-python-bin)) + (if (s-blank wakatime-cli-path) "wakatime " (format "\"%s\" " wakatime-cli-path)) + (buffer-file-name (current-buffer)) + wakatime-user-agent + wakatime-version + (float-time) + (if savep " --write" "") + (if (s-blank wakatime-api-key) "" (format " --key %s" wakatime-api-key)))) +#+end_src + +Also, until [[https://github.com/wakatime/wakatime-cli/issues/509][this issue]] is resolved, I set =wakatime-call= to ignore exit-code 1. +#+begin_src emacs-lisp :tangle no :noweb-ref wakatime-fixes +(defun wakatime-call (savep) + "Call WakaTime command." + (let* + ((command (wakatime-client-command savep)) + (process-environment (if wakatime-python-path (cons (format "PYTHONPATH=%s" wakatime-python-path) process-environment) process-environment)) + (process + (start-process + "Shell" + (generate-new-buffer " *WakaTime messages*") + shell-file-name + shell-command-switch + command))) + + (set-process-sentinel process + `(lambda (process signal) + (when (memq (process-status process) '(exit signal)) + (kill-buffer (process-buffer process)) + (let ((exit-status (process-exit-status process))) + (when (and (not (= 0 exit-status)) (not (= 102 exit-status)) (not (= 1 exit-status))) + (when wakatime-disable-on-error + (wakatime-mode -1) + (global-wakatime-mode -1)) + (cond + ((= exit-status 103) (error "WakaTime Error (%s) Config file parse error. Check your ~/.wakatime.cfg file." exit-status)) + ((= exit-status 104) (error "WakaTime Error (%s) Invalid API Key. Set your api key with: (custom-set-variables '(wakatime-api-key \"XXXX\"))" exit-status)) + ((= exit-status 105) (error "WakaTime Error (%s) Unknown wakatime-cli error. Please check your ~/.wakatime.log file and open a new issue at https://github.com/wakatime/wakatime-mode" exit-status)) + ((= exit-status 106) (error "WakaTime Error (%s) Malformed heartbeat error. Please check your ~/.wakatime.log file and open a new issue at https://github.com/wakatime/wakatime-mode" exit-status)) + (t (message "WakaTime Error (%s) Make sure this command runs in a Terminal: %s" exit-status (wakatime-client-command nil))))))))) + (set-process-query-on-exit-flag process nil))) +#+end_src *** ActivityWatch #+begin_src emacs-lisp (use-package request @@ -4783,6 +4842,9 @@ ERC is a built-it Emacs IRC client. :init (my-leader-def "ai" #'erc-tls) :config + ;; Logging + (setq erc-log-channels-directory "~/.erc/logs") + (setq erc-save-buffer-on-part t) ;; Config of my ZNC instance. (setq erc-server "sqrtminusone.xyz") (setq erc-port 1984) @@ -4793,6 +4855,20 @@ ERC is a built-it Emacs IRC client. (setq erc-track-shorten-start 8)) #+end_src +Exclude everything but actual messages from notifications. +#+begin_src emacs-lisp +(setq erc-track-exclude-types '("NICK" "JOIN" "LEAVE" "QUIT" "PART" + "301" ; away notice + "305" ; return from awayness + "306" ; set awayness + "324" ; modes + "329" ; channel creation date + "332" ; topic notice + "333" ; who set the topic + "353" ; Names notice + )) +#+end_src + A plugin to highlight IRC nicknames: #+begin_src emacs-lisp (use-package erc-hl-nicks