From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Jérôme Haguet" Newsgroups: gmane.emacs.help Subject: Re: [PCL-CVS] Interactive diff on a utf-8 encoded file Date: Thu, 11 Sep 2003 09:54:31 +0200 Organization: Guest of ProXad - France Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3f6029e4$0$13274$626a54ce@news.free.fr> References: <3f5e0162$0$20183$626a54ce@news.free.fr> <3F5E1438.8060804@yahoo.com> <3F5E223D.6020108@yahoo.com> <3f5edef6$0$20172$626a54ce@news.free.fr> <3F5F9F54.4080401@yahoo.com> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1063267554 16617 80.91.224.253 (11 Sep 2003 08:05:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Sep 2003 08:05:54 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 11 10:05:52 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19xMSe-0000wz-01 for ; Thu, 11 Sep 2003 10:05:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19xMQ1-0002N1-S1 for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Sep 2003 04:03:09 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.stueberl.de!proxad.net!feeder2-1.proxad.net!news3-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Original-Lines: 98 Original-NNTP-Posting-Date: 11 Sep 2003 09:53:09 MEST Original-NNTP-Posting-Host: 217.167.42.235 Original-X-Trace: 1063266789 news3-2.free.fr 13274 217.167.42.235:3182 Original-X-Complaints-To: abuse@proxad.net Original-Xref: shelby.stanford.edu gnu.emacs.help:116529 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12451 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12451 Just a last remark : I had to modify > (t (find-operation-coding-system > 'insert-file-contents > file))))) to < (t (car (find-operation-coding-system < 'insert-file-contents < file)))))) to make it work ... Jérôme "Kevin Rodgers" a écrit dans le message de news:3F5F9F54.4080401@yahoo.com... > [Followup-To: gnu.emacs.bug] > > Jérôme Haguet wrote: > > > Hello > > It does not seems to work. > > The following line > > (cvs-coding-system buffer-file-coding-system) > > return the coding-system of *cvs* buffer. > > > Yes, I was afraid it might. > > > > I replace it with > > (cvs-coding-system (find-operation-coding-system 'insert-file-contents > > file))) > > and it give me so far a good result ... > > > Great! > > > But I do not know if it is the correct way to do it. > > > I think it might be more reliable to use buffer-file-coding-system if > the file is being visited in a buffer (which it ought to be), and only > fall back on find-operation-coding-system otherwise. Also, that > function may return "a coding system, a cons of coding systems, or a > function symbol to call". > > So I went looking through the sources to see how it's result is used. > Unfortunately, it's not very consistent, but there's a great example > for us to follow (which supports both points above): vc-coding-system-for-diff > > Here's my latest version, based on that: > > > (defun cvs-retrieve-revision (fileinfo rev) > "Retrieve the given REVision of the file in FILEINFO into a new buffer." > (let* ((file (cvs-fileinfo->full-path fileinfo)) > (rev-file (concat file "." rev))) > (or (find-buffer-visiting rev-file) > (let* ((buffer (find-buffer-visiting file)) > (coding-system (cond ((eq buffer (current-buffer)) > buffer-file-coding-system) > (buffer (with-current-buffer buffer > buffer-file-coding-system)) > (t (find-operation-coding-system > 'insert-file-contents > file))))) > (with-current-buffer (create-file-buffer rev-file) > (message "Retrieving revision %s..." rev) > (let* ((coding-system-for-read coding-system) > (res (call-process cvs-program nil t nil > "-q" "update" "-p" "-r" rev file))) > (when (and res (not (and (equal 0 res)))) > (error "Something went wrong retrieving revision %s: %s" > rev res)) > (set-buffer-modified-p nil) > (let ((buffer-file-name (expand-file-name file))) > (after-find-file)) > (toggle-read-only 1) > (message "Retrieving revision %s... Done" rev) > (current-buffer))))))) > > > Last detail, the coding-system is still not correctly displayed at the > > lower-left corner of the window. > > Hmmm, I'll forward that to gnu.emacs.bug along with our cvs-retrieve-revision. > > -- > Kevin Rodgers >