From 16eb6acc95c00633a6e473e658f676607a21f4ce Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 11 Aug 2008 03:23:54 +0300 Subject: [PATCH] Support for add-change-log-entry kind of functionality. * magit.el (magit-add-log): New, bind it to `C'. --- magit.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/magit.el b/magit.el index c4bdf156..4a89720d 100644 --- a/magit.el +++ b/magit.el @@ -223,6 +223,7 @@ (define-key magit-mode-map (kbd "U") 'magit-pull) (define-key magit-mode-map (kbd "P") 'magit-push) (define-key magit-mode-map (kbd "c") 'magit-log-edit) + (define-key magit-mode-map (kbd "C") 'magit-add-log) (define-key magit-mode-map (kbd "p") 'magit-display-process)) (defvar magit-mode-hook nil) @@ -640,6 +641,39 @@ pushed. (use-local-map magit-log-edit-map) (message "Type C-c C-c to commit."))) +(defun magit-add-log () + (interactive) + (let* ((fun (save-window-excursion + (save-excursion + (magit-visit-thing-at-point) + (add-log-current-defun)))) + (file (magit-diff-info-file (get-text-property (point) + 'magit-info)))) + (magit-log-edit) + (goto-char (point-min)) + (cond ((not (search-forward-regexp (format "^\\* %s" (regexp-quote file)) + nil t)) + ;; No entry for file, create it. + (goto-char (point-max)) + (insert (format "\n* %s (%s): " file fun))) + (t + ;; found entry for file, look for fun + (let ((limit (or (search-forward-regexp "^\\* " nil t) + (point-max)))) + (cond ((search-forward-regexp (format "(.*\\<%s\\>.*):" + (regexp-quote fun)) + limit t) + ;; found it, goto end of current entry + (if (search-forward-regexp "^(" limit t) + (backward-char 2) + (goto-char limit))) + (t + ;; not found insert new entry + (goto-char limit) + (beginning-of-line) + (open-line 1) + (insert (format "(%s): " fun))))))))) + ;;; Miscellaneous (defun magit-ignore-thing-at-point ()