summaryrefslogtreecommitdiff
path: root/.config/emacs/init.el
diff options
context:
space:
mode:
Diffstat (limited to '.config/emacs/init.el')
-rw-r--r--.config/emacs/init.el50
1 files changed, 0 insertions, 50 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el
index 539ddc6..51f18eb 100644
--- a/.config/emacs/init.el
+++ b/.config/emacs/init.el
@@ -618,56 +618,6 @@ rss.xml" anna piracy)
(vc-git--commit-hash-at-point)
(vc-git--select-commit))))
- (defun vc-git-get-commit-hash-at-point ()
- "Get the commit hash at point in the vc log buffer."
- (let ((commit-hash (thing-at-point 'word t)))
- (if (and commit-hash (string-match-p "^[0-9a-f]\\{7,40\\}$" commit-hash))
- commit-hash
- (error "No valid commit hash found at point"))))
-
- (defun vc-git-get-commit-message (commit-hash)
- "Retrieve the commit message for COMMIT-HASH."
- (with-temp-buffer
- (if (zerop (vc-git-command t 0 nil "log" "--format=%B" "-n" "1" commit-hash))
- (buffer-string)
- (error "Failed to retrieve commit message for %s" commit-hash))))
-
- (defun vc-git-setup-log-edit-buffer (commit-message)
- "Set up a log edit buffer with COMMIT-MESSAGE."
- (let ((log-edit-buffer (get-buffer-create "*VC Reword Commit*")))
- (with-current-buffer log-edit-buffer
- (erase-buffer)
- (insert commit-message)
- (vc-git-log-edit-mode))
- log-edit-buffer))
-
- (defun vc-git-save-and-amend-commit (commit-hash)
- "Save the commit message from the current buffer and amend COMMIT-HASH."
- (let ((commit-msg-file (make-temp-file "git-commit-msg")))
- (write-region (point-min) (point-max) commit-msg-file)
- (vc-git-command nil 0 nil "commit" "--amend" "--file" commit-msg-file)
- (delete-file commit-msg-file)
- (message "Commit message reworded.")))
- ;; TODO: Fix this!
- (defun vc-git-reword-commit-at-point ()
- "Reword the commit message of the commit at point in the vc log buffer."
- (interactive)
- (let* ((commit-hash (vc-git-get-commit-hash-at-point))
- (commit-message (vc-git-get-commit-message commit-hash))
- (log-edit-buffer (vc-git-setup-log-edit-buffer commit-message)))
- ;; Bind C-c C-c to save changes and amend the commit
- (with-current-buffer log-edit-buffer
- (setq-local vc-log-operation 'commit)
- (setq-local vc-log-after-commit-function
- `(lambda (&rest _args)
- (vc-git-save-and-amend-commit ,commit-hash)
- (kill-buffer ,log-edit-buffer)))
- (local-set-key (kbd "C-c C-c")
- (lambda ()
- (interactive)
- (run-hooks 'vc-log-after-commit-function)))
- (pop-to-buffer log-edit-buffer))))
-
(defun vc-git-format-patches (num)
"Format patches for NUM of last commits"
(interactive (list (read-number "Number of commits: ")))