* [PCL-CVS] Interactive diff on a utf-8 encoded file
@ 2003-09-09 16:37 Jérôme Haguet
2003-09-09 17:56 ` Kevin Rodgers
0 siblings, 1 reply; 6+ messages in thread
From: Jérôme Haguet @ 2003-09-09 16:37 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 630 bytes --]
Hello
I have
- GNU Emacs 21.3 on Windows
- a CVS checkout in which most of the files are encoded in ISO-8859-1 and
some others in UTF-8.
All the utf-8 encoded files have the .utf extension
I have added in my .emacs the following line :
(add-to-list 'file-coding-system-alist (list "\\.utf" 'utf-8))
prefer-coding-system is set to 'iso-latin-1
Everything works fine when I open a file (Emacs set the right coding system)
My problem is when I run interactive diff from PCL-CVS (d e)
Emacs always set the coding system of the BASE version of the .utf files to
iso-8859-1
Any idea how to fix this ?
Thank you in advance.
Jérôme
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PCL-CVS] Interactive diff on a utf-8 encoded file
2003-09-09 16:37 [PCL-CVS] Interactive diff on a utf-8 encoded file Jérôme Haguet
@ 2003-09-09 17:56 ` Kevin Rodgers
2003-09-09 18:55 ` Kevin Rodgers
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2003-09-09 17:56 UTC (permalink / raw)
Jérôme Haguet wrote:
> Hello
> I have
> - GNU Emacs 21.3 on Windows
> - a CVS checkout in which most of the files are encoded in ISO-8859-1 and
> some others in UTF-8.
>
> All the utf-8 encoded files have the .utf extension
> I have added in my .emacs the following line :
> (add-to-list 'file-coding-system-alist (list "\\.utf" 'utf-8))
> prefer-coding-system is set to 'iso-latin-1
>
> Everything works fine when I open a file (Emacs set the right coding system)
>
> My problem is when I run interactive diff from PCL-CVS (d e)
> Emacs always set the coding system of the BASE version of the .utf files to
> iso-8859-1
>From pcvs.el:
;;; Bugs:
;; - Extracting an old version seems not to recognize encoding correctly.
;; That's probably because it's done via a process rather than a file.
> Any idea how to fix this ?
Maybe cvs-retrieve-revision can be hacked. Does this *untested* patch work?
*** emacs-21.3/lisp/pcvs.el.orig Sat Sep 22 14:23:16 2001
--- emacs-21.3/lisp/pcvs.el Tue Sep 9 11:54:55 2003
***************
*** 1519,1526 ****
(or (find-buffer-visiting buffile)
(with-current-buffer (create-file-buffer buffile)
(message "Retrieving revision %s..." rev)
! (let ((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)
--- 1519,1529 ----
(or (find-buffer-visiting buffile)
(with-current-buffer (create-file-buffer buffile)
(message "Retrieving revision %s..." rev)
! (let* ((process-coding-system-alist
! (list (cons (regexp-quote cvs-program)
!
buffer-file-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)
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PCL-CVS] Interactive diff on a utf-8 encoded file
2003-09-09 17:56 ` Kevin Rodgers
@ 2003-09-09 18:55 ` Kevin Rodgers
2003-09-10 8:22 ` Jérôme Haguet
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2003-09-09 18:55 UTC (permalink / raw)
Kevin Rodgers wrote:
> From pcvs.el:
>
>
> ;;; Bugs:
>
> ;; - Extracting an old version seems not to recognize encoding correctly.
> ;; That's probably because it's done via a process rather than a file.
>
>
> > Any idea how to fix this ?
>
> Maybe cvs-retrieve-revision can be hacked. Does this *untested* patch
> work?
Here's a better patch, that tries to take into account the fact that
buffer-file-coding-system is buffer local:
*** emacs-21.3/lisp/pcvs.el.orig Sat Sep 22 14:23:16 2001
--- emacs-21.3/lisp/pcvs.el Tue Sep 9 12:54:51 2003
***************
*** 1515,1526 ****
(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))
! (buffile (concat file "." rev)))
(or (find-buffer-visiting buffile)
(with-current-buffer (create-file-buffer buffile)
(message "Retrieving revision %s..." rev)
! (let ((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)
--- 1515,1529 ----
(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))
! (buffile (concat file "." rev))
! (cvs-coding-system buffer-file-coding-system))
(or (find-buffer-visiting buffile)
(with-current-buffer (create-file-buffer buffile)
(message "Retrieving revision %s..." rev)
! (let* ((process-coding-system-alist
! (list (cons (regexp-quote cvs-program) cvs-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)
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PCL-CVS] Interactive diff on a utf-8 encoded file
2003-09-09 18:55 ` Kevin Rodgers
@ 2003-09-10 8:22 ` Jérôme Haguet
2003-09-10 22:01 ` Kevin Rodgers
0 siblings, 1 reply; 6+ messages in thread
From: Jérôme Haguet @ 2003-09-10 8:22 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2665 bytes --]
Hello
It does not seems to work.
The following line
(cvs-coding-system buffer-file-coding-system)
return the coding-system of *cvs* buffer.
I replace it with
(cvs-coding-system (find-operation-coding-system 'insert-file-contents
file)))
and it give me so far a good result ...
But I do not know if it is the correct way to do it.
Last detail, the coding-system is still not correctly displayed at the
lower-left corner of the window.
Anyway, thanks for your help.
"Kevin Rodgers" <ihs_4664@yahoo.com> a écrit dans le message de
news:3F5E223D.6020108@yahoo.com...
> Kevin Rodgers wrote:
>
> > From pcvs.el:
> >
> >
> > ;;; Bugs:
> >
> > ;; - Extracting an old version seems not to recognize encoding
correctly.
> > ;; That's probably because it's done via a process rather than a file.
> >
> >
> > > Any idea how to fix this ?
> >
> > Maybe cvs-retrieve-revision can be hacked. Does this *untested* patch
> > work?
>
> Here's a better patch, that tries to take into account the fact that
> buffer-file-coding-system is buffer local:
>
> *** emacs-21.3/lisp/pcvs.el.orig Sat Sep 22 14:23:16 2001
> --- emacs-21.3/lisp/pcvs.el Tue Sep 9 12:54:51 2003
> ***************
> *** 1515,1526 ****
> (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))
> ! (buffile (concat file "." rev)))
> (or (find-buffer-visiting buffile)
> (with-current-buffer (create-file-buffer buffile)
> (message "Retrieving revision %s..." rev)
> ! (let ((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)
> --- 1515,1529 ----
> (defun cvs-retrieve-revision (fileinfo rev)
> "Retrieve the given REVision of the file in FILEINFO into a new buffe
r."
> (let* ((file (cvs-fileinfo->full-path fileinfo))
> ! (buffile (concat file "." rev))
> ! (cvs-coding-system buffer-file-coding-system))
> (or (find-buffer-visiting buffile)
> (with-current-buffer (create-file-buffer buffile)
> (message "Retrieving revision %s..." rev)
> ! (let* ((process-coding-system-alist
> ! (list (cons (regexp-quote cvs-program) cvs-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)
>
> --
> Kevin Rodgers
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PCL-CVS] Interactive diff on a utf-8 encoded file
2003-09-10 8:22 ` Jérôme Haguet
@ 2003-09-10 22:01 ` Kevin Rodgers
2003-09-11 7:54 ` Jérôme Haguet
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2003-09-10 22:01 UTC (permalink / raw)
[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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PCL-CVS] Interactive diff on a utf-8 encoded file
2003-09-10 22:01 ` Kevin Rodgers
@ 2003-09-11 7:54 ` Jérôme Haguet
0 siblings, 0 replies; 6+ messages in thread
From: Jérôme Haguet @ 2003-09-11 7:54 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3407 bytes --]
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" <ihs_4664@yahoo.com> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-09-11 7:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-09 16:37 [PCL-CVS] Interactive diff on a utf-8 encoded file Jérôme Haguet
2003-09-09 17:56 ` Kevin Rodgers
2003-09-09 18:55 ` Kevin Rodgers
2003-09-10 8:22 ` Jérôme Haguet
2003-09-10 22:01 ` Kevin Rodgers
2003-09-11 7:54 ` Jérôme Haguet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).