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: Mickey Ferguson
Subject: Re: reading binary, non-unix file
Date: Tue, 26 Oct 2004 10:00:17 -0700

"Mathias Dahl" <brakjoller@gmail.com> wrote in message
uis8x6e8i.fsf@gmail.com">news:uis8x6e8i.fsf@gmail.com...
> "Mickey Ferguson" <MFerguson@peinc.com> writes:
> > Second, after I determine which one of the above to use, can anyone
> > help me to write a function so that I can then map a key combination
> > (similar to C-X C-F uses Find-File), that will load in the proper
> > coding and then find the file?  I'm lisp-impaired, so any help would
> > be appreciated.  I'm capable of taking an interactive function
> > that's been defined and mapping it to a keystroke, but that's about
> > it.
>
> 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>.

One thing I omitted in my requirements specification was that I cannot just
bind this utf-16-le coding to a particular file type (e.g. *.log).  I need
to be able to do it on a file-by-file basis.

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])

This results in a very large minibuffer error message, which is pretty much
incomprehensible to me.

OK, I tried a different tack.  I tried this function definition, taking a
completely wild stab in the dark, based on what one of the other helpful
responders suggested for the underlying functions.  It's probably completely
messed up, but I bet one of the lisp gurus out there can figure out how to
fix it.  Basically, what I want this function to do is to perform the
equivalent of having performed a C-x <enter> c, specifying the utf-16-le
encoding, followed by a regular find-file operation.  In general, I like
this approach much better than the previous approach, but I also prefer to
use something that actually works, instead of failing :-), so whatever we
can get to solve the problem is good for me!

Here's the (completely wrong) code:

;;; define function to load in a unicode file (utf-16-le encoding)
(defun find-unicode-file (filename)
  "Run find-file on a unicode (utf-16-le encoding) file."
  (interactive "FFind unicode file: \np")
  (universal-coding-system-argument "utf-16-le")
  (find-file filename)
  )




reply via email to

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