Re: File name completion on Mac OS X with German umlauts
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: File name completion on Mac OS X with German umlauts         

Group: gnu.emacs.help · Group Profile
Author: Nikolaj Schumacher
Date: Mar 18, 2008 11:05

Eli Zaretskii gnu.org> wrote:
>> From: Nikolaj Schumacher
>>
>> This is very interesting. Apparently `read-file-name' doesn't use
>> `file-name-coding-system' when completing.
>
> How do you see that? Just looking at the sources, I see it does.

Sorry, I phrased that poorly. I only intended to express a suspicion...

After some actual research, I the real reason appears to be that
utf-8m.el only offers one-way transformation and `read-file-name' needs
the other direction.

A naive attempt of adding that worked surprisingly well. The only issue
I have is that Emacs always says "Complete, but not unique". Don't know
why, yet.

(require 'utf-8m)

(defun utf-8m-pre-write-conversion (beg end)
(save-excursion ;; conversion (NFC -> NFD)
(save-restriction
(narrow-to-region beg end)
(let ((str (buffer-string)))
(delete-region (point-min) (point-max))
(insert
(decode-coding-string
(or (mac-code-convert-string
(encode-coding-string str 'utf-8) 'utf-8 'utf-8 'NFD) "")
'utf-8)
))
)))

(make-coding-system
'utf-8m-alt 4 ?U
"modified UTF-8 encoding for Mac OS X hfs plus volume format."
'(ccl-decode-mule-utf-8 . ccl-encode-mule-utf-8)
`((safe-charsets
ascii
eight-bit-control
eight-bit-graphic
latin-iso8859-1
mule-unicode-0100-24ff
mule-unicode-2500-33ff
mule-unicode-e000-ffff
,@(if utf-translate-cjk-mode
utf-translate-cjk-charsets))
(mime-charset . nil)
(coding-category . coding-category-utf-8)
(valid-codes (0 . 255))
(pre-write-conversion . ,(if (fboundp 'mac-code-convert-string)
'utf-8m-pre-write-conversion
'utf-8-pre-write-conversion))
,(if (functionp 'mac-code-convert-string)
'(post-read-conversion . utf-8m-e22-mac-post-read-conversion)
'(post-read-conversion . utf-8m-e22-post-read-conversion))
(translation-table-for-encode . utf-translation-table-for-encode)
(dependency unify-8859-on-encoding-mode
unify-8859-on-decoding-mode
utf-fragment-on-decoding
utf-translate-cjk-mode)))

(require 'utf-8m-alt)
(setq file-name-coding-system 'utf-8m-alt)

regards,
Nikolaj Schumacher
no comments
diggit! del.icio.us! reddit!