From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: Magit and seeing the whole diff Date: Tue, 21 Dec 2010 10:31:36 +0100 Message-ID: <87vd2nzd3b.fsf@ambire.localdomain> References: <87y67m6n0i.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1292924265 19015 80.91.229.12 (21 Dec 2010 09:37:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 21 Dec 2010 09:37:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 21 10:37:41 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PUyf2-0000tQ-Ai for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Dec 2010 10:37:36 +0100 Original-Received: from localhost ([127.0.0.1]:48291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUyey-0008BJ-Cz for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Dec 2010 04:37:32 -0500 Original-Received: from [140.186.70.92] (port=52670 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUye8-0008AC-Kq for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 04:36:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PUye7-00051a-ED for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 04:36:40 -0500 Original-Received: from smtp206.alice.it ([82.57.200.102]:41656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PUye7-00051P-2K for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 04:36:39 -0500 Original-Received: from ambire.localdomain (95.244.66.231) by smtp206.alice.it (8.5.124.08) id 4C1A268C0D255980 for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 10:36:36 +0100 Original-Received: from ttn by ambire.localdomain with local (Exim 4.69) (envelope-from ) id 1PUyZF-0000ra-8i for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 10:31:37 +0100 In-Reply-To: (Andrea Crotti's message of "Mon, 20 Dec 2010 14:06:44 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77714 Archived-At: () Andrea Crotti () Mon, 20 Dec 2010 14:06:44 +0100 I don't quite get what you mean... How does this integrates with magit/emacs? Sorry, i sent the mail out before completing it. That shell script in fact doesn't integrate with anything, because i haven't found any Emacs Lisp wrapping that lets me play (fully) with all the git diff variants and options. You keep a buffer with the diff and you revert it sometimes? Yes. The shell script (aka $0 aka .ttn.diff) rewrites its tail on every invocation (it requires a sed that supports =E2=80=98-i=E2=80=99, lik= e GNU sed). Typically, i futz the command line to taste then move point after the close-paren and type =E2=80=98C-x C-e=E2=80=99. This invokes the= script and reverts the buffer; btw, here is =E2=80=98revert-buffer-t-t=E2=80=99: (defun revert-buffer-t-t () (interactive) (revert-buffer t t)) The file is automatically placed into Diff mode because of its name. I usually immediately type =E2=80=98C-x C-q=E2=80=99 to toggle read-= only, which enables =E2=80=98n=E2=80=99 and =E2=80=98p=E2=80=99 bindings to for f= ast cruising, etc. I suppose all of this can be translated into an Emacs Lisp command. Here's a lightly-tested sketch that does more or less (it moves point, annoyingly) the same thing: (defun update-diff () "Update the current buffer using its \"git diff\" command. The command should be near the beginning of the file at bol, and start with \"git diff\" (so \"git diff-index\", etc, is ok). It should be followed at some point by #### on a line by itself. For example: #git diff-index [...] ;; unused #git diff a q ;; unused git diff -p --stat q r/hack #git diff -p --stat q r/fix ;; unused #### The updated buffer has a time stamp and the output of the git diff command. It is in Diff mode, read-only." (interactive) (let ((me (buffer-file-name)) (cmd (progn (goto-char (point-min)) (re-search-forward "^git diff") (buffer-substring (match-beginning 0) (line-end-position))))) (re-search-forward "^####.*\n") (let ((inhibit-read-only t)) (delete-region (point) (point-max)) (save-excursion (insert (format-time-string "\n\t\t\t\t\t\t%F %T\n\n") (shell-command-to-string cmd)))) (diff-mode) (toggle-read-only 1))) Now that i've written it, probably i'll stop using the shell script. So, thanks for prompting this pleasant interlude!