Hi Eric! I have created a helper for reviewing darcs patches in emacs. To use it save .dpatch on disk and run darcs-review function. Attached patch is for darcs-team repo.
Hopefully it would be usefull for those who prefer emacs to vim :) BTW this is my first elisp experience so comments are very welcome. Regards, Dmitry Sun Nov 16 19:14:23 MSK 2008 Dmitry Kurochkin <[EMAIL PROTECTED]> * darcs-review module for emacs. Provides darcs-review function which takes a darcs patch and formats it nicely for review.
New patches: [darcs-review module for emacs. Dmitry Kurochkin <[EMAIL PROTECTED]>**20081116161423 Ignore-this: d5b892171235b47b7d7153d07bcd4014 Provides darcs-review function which takes a darcs patch and formats it nicely for review. ] addfile ./darcs-review.el hunk ./darcs-review.el 1 +;; Formats darcs patches for easy review. +;; +;; Put into your load-path and add +;; +;; (require 'darcs-review) +;; +;; to .emacs +;; +;; Run M-x darcs-review and specify darcs patch. +;; +;; Author: Dmitry Kurochkin <[EMAIL PROTECTED]> +;; + +(provide 'darcs-review) + +(require 'ido) +(require 'diff-mode) + +(defun darcs-review (&optional darcs-patch) + "Review darcs patch." + (interactive) + (let ((filename (if darcs-patch + darcs-patch + (ido-read-file-name "Select darcs patch: ")))) + (if (file-exists-p filename) + (progn + (switch-to-buffer (generate-new-buffer (concat "darcs-review: " filename))) + (diff-mode) + (insert-file-contents filename) + (darcs-review-delete-text-before-patches) + (darcs-review-delete-text-after-patches) + (goto-char (point-min)) + (darcs-review-mark-patches) + (goto-char (point-min))) + (display-message-or-buffer (format "Filename '%s' does not exist" filename))))) + +(defun darcs-review-delete-text-before-patches () + "Remove all text before the first patch." + (goto-char (point-min)) + (search-forward-regexp "^\nNew patches:\n\n\\[") + (backward-char) + (delete-region (point-min) (point))) + +(defun darcs-review-delete-text-after-patches () + "Remove all text after the last patch." + (goto-char (point-max)) + (search-backward "\n\nContext:\n\n[") + (forward-char) + (delete-region (point) (point-max))) + +(defun darcs-review-mark-patches () + "Mark all patches." + (delete-char 1) + (let ((patch-begin (point))) + (forward-line) + (insert-char ?- (- (point) patch-begin 1))) + (newline) + (forward-line) + (let ((patch-description (point))) + (search-forward-regexp "^\\] ") + (delete-region patch-description (point))) + (while (not (or (eq (point) (point-max)) + (search-forward-regexp "^\\[" (forward-point 1) t))) + (if (search-forward-regexp "^[ +\-]" (forward-point 1) t) + (progn (backward-char) + (insert "> ")) + (newline)) + (forward-line)) + (when (not (eq (point) (point-max))) + (backward-char) + (newline) + (newline) + (darcs-review-mark-patches))) Context: [Applied-thanks template Eric Kow <[EMAIL PROTECTED]>**20081109181922 Ignore-this: 7fc0b7551d61ef8950dea60ee2f414ad ] [Vim integration Eric Kow <[EMAIL PROTECTED]>**20081109181916 Ignore-this: 2d69aaa79bdef4f48a79755b01823cad ] [Changelog tools Eric Kow <[EMAIL PROTECTED]>**20081109181755 Ignore-this: 7d14d4c6a3a3b9ca1b8a548ba0873f4e Note that make_changelog.hs comes from darcs ] [Patch review sed script Eric Kow <[EMAIL PROTECTED]>**20081109181737 Ignore-this: a6a26e680e0f7e182110a0edd2475b4c ] Patch bundle hash: 78545a393f44cb324dfdf2ab830afebe8ee8d86b
_______________________________________________ darcs-users mailing list [email protected] http://lists.osuosl.org/mailman/listinfo/darcs-users
