From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Magit and seeing the whole diff
Date: Tue, 21 Dec 2010 10:31:36 +0100 [thread overview]
Message-ID: <87vd2nzd3b.fsf@ambire.localdomain> (raw)
In-Reply-To: <m1oc8gioez.fsf@ip1-201.halifax.rwth-aachen.de> (Andrea Crotti's message of "Mon, 20 Dec 2010 14:06:44 +0100")
() Andrea Crotti <andrea.crotti.0@gmail.com>
() 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 ‘-i’, like GNU
sed). Typically, i futz the command line to taste then move point
after the close-paren and type ‘C-x C-e’. This invokes the script
and reverts the buffer; btw, here is ‘revert-buffer-t-t’:
(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 ‘C-x C-q’ to toggle read-only,
which enables ‘n’ and ‘p’ bindings to for fast 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!
next prev parent reply other threads:[~2010-12-21 9:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-18 20:21 Magit and seeing the whole diff Andrea Crotti
2010-12-19 11:05 ` Thien-Thi Nguyen
2010-12-20 13:06 ` Andrea Crotti
2010-12-21 9:31 ` Thien-Thi Nguyen [this message]
[not found] <mailman.9.1292703974.5735.help-gnu-emacs@gnu.org>
2010-12-20 12:48 ` Sébastien Vauban
2010-12-20 13:51 ` Andrea Crotti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vd2nzd3b.fsf@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.