[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: buff-menu.el in CVS today has utf-8 characters?
From: |
Drew Adams |
Subject: |
RE: buff-menu.el in CVS today has utf-8 characters? |
Date: |
Tue, 14 Jun 2005 15:28:13 -0700 |
My bad. I clicked the download link, which opened the file in my browser (IE);
I then selected the text and pasted it into Emacs.
When, instead, I right-click to Save Target As, I get the file with em dashes.
I wonder if other users might do the same as I.
I byte-compiled in Emacs 20, for compatibility, and got this warning:
While compiling list-buffers-noselect:
** reference to free variable \200\224
If I byte-compile in Emacs 22 I don't get the warning. I want to adapt the file
(locally) for Emacs 20 too. Any idea what I'll need to do wrt "free variable
\200\224"? I guess that the byte-compiler is interpreting the UTF em-dash
character as a variable named \200\244 following character ?\342 when it sees a
character code like this: ?\342\200\224.
What's the best way to prevent execution of the Emacs 22 code for this
character? I know you will say that testing the Emacs version is not the way to
go. What's a better test to use here?
Thanks,
Drew
-----Original Message-----
From: Stefan Monnier [mailto:address@hidden
Sent: Tuesday, June 14, 2005 3:08 PM
To: Drew Adams
Cc: Emacs-Pretest-Bug
Subject: Re: buff-menu.el in CVS today has utf-8 characters?
> In the minibuffer, it says "Select coding system (default
mule-utf-8):"
> Point is on this in buff-menu.el: –-Stef
> Questions:
> Is it normal to have these characters in the file?
I don't see them here. Are they present in the buff-menu.el
buffer as well?
If not, how do you copy&paste from buff-menu.el to foo.el?
> Does this file need to be utf-8? Should it be?
Well, there are a few other coding systems possible, but it contains
a non-ASCII non-latin-1 char (more specifically an EM DASH, U+2014).
> What coding system should I use to save this file? I used utf-8.
Good choice.
> The first line of the buffer has this - shouldn't it force utf-8
> encoding automatically? -*- coding:utf-8 -*-
I agree it should force utf-8 automatically. I use the patch below for
that precise purpose.
Stefan
--- orig/lisp/international/mule-cmds.el
+++ mod/lisp/international/mule-cmds.el
@@ -854,6 +855,24 @@
(mapcar (function (lambda (x) (cons x (coding-system-base x))))
default-coding-system))
+ (unless no-other-defaults
+ ;; If the file has a coding cookie, try to use it before anything
+ ;; else (i.e. before default-coding-system which will
typically come
+ ;; from file-coding-system-alist).
+ (unless (or (stringp from) find-file-literally)
+ (let* ((auto-cs (save-excursion
+ (save-restriction
+ (widen)
+ (narrow-to-region from to)
+ (goto-char (point-min))
+ (set-auto-coding (or file
buffer-file-name "")
+ (buffer-size)))))
+ (base (if auto-cs (coding-system-base auto-cs))))
+ (or (memq base '(nil undecided))
+ (rassq base default-coding-system)
+ (push (cons auto-cs base)
+ default-coding-system)))))
+
;; From now on, the list of defaults is reversed.
(setq default-coding-system (nreverse default-coding-system))