From 962b4c9251329703b040cb3a074538e411870a99 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Fri, 22 Nov 2013 13:16:15 +0000 Subject: [PATCH] Premiere version fonctionnelle du refactoring extract-method --- .../emacs/refactoring-browser/refactoring.el | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/scripts/emacs/refactoring-browser/refactoring.el b/scripts/emacs/refactoring-browser/refactoring.el index 735fe7e7c54..7795272a67a 100644 --- a/scripts/emacs/refactoring-browser/refactoring.el +++ b/scripts/emacs/refactoring-browser/refactoring.el @@ -6,6 +6,7 @@ (let ( (current-dir (file-name-directory (symbol-file 'refactoring-extract-method))) (file-name (buffer-file-name (current-buffer))) + (point (region-beginning)) (start-line (line-number-at-pos (region-beginning))) (end-line (line-number-at-pos (region-end))) (refactoring-command) @@ -19,16 +20,30 @@ (shell-command refactoring-command - (switch-to-buffer refactoring-buffer) + refactoring-buffer ) (if (y-or-n-p "Apply refactoring ?") - (progn - (shell-command - (concat refactoring-command "|patch -p1"))) - ) + (progn + (switch-to-buffer patched-file-buffer) + (erase-buffer) + (shell-command + (concat refactoring-command "|patch -p1 -o -") patched-file-buffer refactoring-buffer) + (goto-char point) + ) + ) - (kill-buffer) - (revert-buffer) + (kill-buffer refactoring-buffer) + (switch-to-buffer patched-file-buffer) + ) ) -) + + +(defun refactoring-revert-buffer-keep-undo(buffer) + "Revert buffer but keep undo history." + (switch-to-buffer buffer) + (let ((inhibit-read-only t)) + (erase-buffer) + (insert-file-contents (buffer-file-name)) + (set-visited-file-modtime (visited-file-modtime)) + (set-buffer-modified-p nil))) -- GitLab