From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Mickey Ferguson" Newsgroups: gmane.emacs.help Subject: Re: reading binary, non-unix file Date: Tue, 26 Oct 2004 10:00:17 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1098810145 5317 80.91.229.6 (26 Oct 2004 17:02:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Oct 2004 17:02:25 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 26 19:02:20 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CMUiC-0007md-00 for ; Tue, 26 Oct 2004 19:02:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CMUpt-0008Ll-NC for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Oct 2004 13:10:17 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!irazu.switch.ch!switch.ch!npeer.de.kpn-eurorings.net!border2.nntp.ams.giganews.com!nntp.giganews.com!uio.no!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Original-NNTP-Posting-Host: 12.9.209.10 Original-X-Trace: quimby.gnus.org 1098809854 13012 12.9.209.10 (26 Oct 2004 16:57:34 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Tue, 26 Oct 2004 16:57:34 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Original-Xref: shelby.stanford.edu gnu.emacs.help:126075 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21453 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21453 "Mathias Dahl" wrote in message news:uis8x6e8i.fsf@gmail.com... > "Mickey Ferguson" 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 > and then insert it so that it acts as a function (sort of) in your > .emacs with M-x insert-kbd-macro . 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 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) )