From ec6a536af0237b818dc43b01d5e38193e8078fb1 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 29 Dec 2020 19:15:32 +0100 Subject: Make killing commands more verbose Also add helper to copy Message-Id from Gnus summary. --- .emacs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/.emacs b/.emacs index b21a3f7..7fb5d68 100644 --- a/.emacs +++ b/.emacs @@ -96,9 +96,13 @@ (set-variable 'tab-width new-width) (message "changed from %s to %s" old-width new-width))) +(defun my/kill (stuff) + (kill-new stuff) + (message "Copied \"%s\"" stuff)) + (defun my/kill-ring-filename () (interactive) - (kill-new (or (buffer-file-name) default-directory))) + (my/kill (or (buffer-file-name) default-directory))) (defun my/kill-ring-pipe-region (command) (interactive (list (read-shell-command "Shell command on region: "))) @@ -107,13 +111,13 @@ (insert input) (call-process-region (point-min) (point-max) shell-file-name t t nil shell-command-switch command) - (kill-new (buffer-string))))) + (my/kill (buffer-string))))) (defun my/kill-ring-shell (command) (interactive (list (read-shell-command "Shell command: "))) (with-temp-buffer (call-process-shell-command command nil t) - (kill-new (buffer-string)))) + (my/kill (buffer-string)))) (defun my/make-project-wide (f) "Make a function which will run F from the project's root directory." @@ -271,18 +275,13 @@ (defun my/describe-revision (rev) "Format a Git revision in a format suitable for changelogs." (interactive - (list - (let* ((rev (my/revision-at-point)) - (prompt (format-prompt "Revision" rev))) - (read-string prompt nil nil rev)))) - (let* ((rev-fmt "%cd \"%s\" (%h)") - (desc - (string-trim - (shell-command-to-string - (format "git show --no-patch --date=short --format='%s' %s" - rev-fmt rev))))) - (kill-new desc) - (message desc))) + (list (let ((rev (my/revision-at-point))) + (read-string (format-prompt "Revision" rev) + nil nil rev)))) + (my/kill (string-trim + (shell-command-to-string + (format "git show --no-patch --date=short --format='%s' %s" + "%cd \"%s\" (%h)" rev))))) ;; Major modes configuration @@ -387,6 +386,10 @@ (my/unfroggify) (my/froggify))) +(defun my/message-id () + (interactive) + (my/kill (mail-header-message-id (gnus-summary-article-header)))) + ;; Font stuff 🤷🤦. Emacs comes with sensible defaults (e.g. the ;; default fontset includes Symbola for various subgroups of the ;; "symbol" script), but no color font by default. -- cgit v1.2.3