help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: reading binary, non-unix file


From: Mathias Dahl
Subject: Re: reading binary, non-unix file
Date: 27 Oct 2004 09:46:20 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

"Mickey Ferguson" <MFerguson@peinc.com> writes:

> > You start and stop a keyboard macro with C-x ( and C-x )
> > respectively. You can then name it with M-x name-last-kbd-macro <name>
> > and then insert it so that it acts as a function (sort of) in your
> > .emacs with M-x insert-kbd-macro <name>.
> 
> ...
> Given the above information, I tried your suggestion above, and I've
> definitely got something wrong.  I tried the following, for which the fset
> is the result of using the C-x ( and C-x ):
> 
> ;;; define function to load in a unicode file (utf-16-le encoding)
> (fset 'find-unicode-file
>    [?\C-x return ?c ?u ?t ?f ?- ?1 ?6 ?- ?l ?e])

You are right, that did not work. When I used a keyboard for doing
this a while back it was for *saving* files. It seems that it does not
work with C-x C-f, leaving out the file name.

I looked at how universal-coding-system-argument works and hacked
together the following, which seems to do what you want:

(defun find-unicode-file ()
  "Run find-file on a unicode (utf-16-le encoding) file."
  (interactive)
  (let* ((coding-system 'utf-16-le)
         (coding-system-for-read coding-system)
         (coding-system-require-warning t))
    (call-interactively 'find-file)))

Hope it works for you.

/Mathias


reply via email to

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