[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PCL-CVS] Interactive diff on a utf-8 encoded file

From: Kevin Rodgers
Subject: Re: [PCL-CVS] Interactive diff on a utf-8 encoded file
Date: Wed, 10 Sep 2003 16:01:56 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv: Gecko/20020406 Netscape6/6.2.2

[Followup-To: gnu.emacs.bug]

Jérôme Haguet wrote:

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
and it give me so far a good result ...


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 (with-current-buffer buffer
                                   (t (find-operation-coding-system
         (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)))
             (toggle-read-only 1)
             (message "Retrieving revision %s... Done" rev)

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]