diff options
Diffstat (limited to 'tools/emacs/config/functions.el')
-rw-r--r-- | tools/emacs/config/functions.el | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/emacs/config/functions.el b/tools/emacs/config/functions.el index 2b9713006837..1bec8ecd98a7 100644 --- a/tools/emacs/config/functions.el +++ b/tools/emacs/config/functions.el @@ -203,7 +203,7 @@ (save-excursion (move-end-of-line nil) (insert (format " %s TODO(%s): %s" - comment-start + (s-trim-right comment-start) (if prefix (read-string "Who needs to do this? ") (getenv "USER")) todo)))) @@ -238,4 +238,31 @@ (if prefix (text-scale-adjust 0) (set-face-attribute 'default nil :height (or to 120)))) +(defun notmuch-depot-apply-patch () + "Apply the currently opened notmuch message as a patch on the + depot." + + (interactive) + ;; The implementation works by letting notmuch render a raw message + ;; and capturing it by overriding the `view-buffer' function it + ;; calls after rendering. + ;; + ;; The buffer is then passed to `git-am'. + (cl-letf (((symbol-function 'view-buffer) + (lambda (buffer &optional exit-action) buffer))) + (if-let ((raw-buffer (notmuch-show-view-raw-message))) + (progn + (with-current-buffer raw-buffer + (call-shell-region (point-min) (point-max) "git am -C ~/depot") + (message "Patch applied!") + (kill-buffer)) + (magit-status "~/depot")) + (warn "notmuch failed to render the raw message buffer")))) + +(defun scrot-select () + "Take a screenshot based on a mouse-selection and save it to + ~/screenshots." + (interactive) + (shell-command "scrot '$a_%s.png' -s -e 'mv $f ~/screenshots/'")) + (provide 'functions) |