From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: kj Newsgroups: gmane.emacs.help Subject: Re: How to convert this macro to Elisp? Date: Tue, 16 Feb 2010 14:27:21 +0000 (UTC) Organization: none Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1266332447 21036 80.91.229.12 (16 Feb 2010 15:00:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Feb 2010 15:00:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 16 16:00:45 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NhOuU-0007Ut-7r for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Feb 2010 16:00:40 +0100 Original-Received: from localhost ([127.0.0.1]:45289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhOuF-0004aO-PQ for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Feb 2010 10:00:07 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!panix!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-NNTP-Posting-Host: panix2.panix.com Original-X-Trace: reader2.panix.com 1266330441 6603 166.84.1.2 (16 Feb 2010 14:27:21 GMT) Original-X-Complaints-To: abuse@panix.com Original-NNTP-Posting-Date: Tue, 16 Feb 2010 14:27:21 +0000 (UTC) X-No-Confirm: yes User-Agent: nn/6.7.3 Original-Xref: news.stanford.edu gnu.emacs.help:176819 X-Mailman-Approved-At: Tue, 16 Feb 2010 09:56:48 -0500 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: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71890 Archived-At: In Harald Hanche-Olsen writes: >+ kj : >> I have a macro that I want to convert to Elisp. Furthermore, I >> want the resulting code to be completely non-interactive. >> >> Here's what the macro looks like: >> >> C-x RET c ;; universal-coding-system-argument >> euc-jp ;; self-insert-command * 6 >> RET ;; newline >> C-x C-f ;; find-file >> test ;; self-insert-command * 4 >> RET ;; newline >> C-x RET f ;; set-buffer-file-coding-system >> utf-8 ;; self-insert-command * 5 >> RET ;; newline >> C-x C-s ;; save-buffer >> raw-text ;; self-insert-command * 8 >> RET ;; newline >> >> How can I convert this to Elisp? >Something like this might work (not properly tested): >(defun select-utf-8-or-raw (from to &rest _) > (if (memq 'utf-8 (find-coding-systems-region from to)) > 'utf-8 'raw-text)) >(defun change-file-coding-to-utf-8 (filename from-coding) > (let ((coding-system-for-read from-coding)) > (find-file filename) > (set-buffer-file-coding-system 'utf-8) > (let ((select-safe-coding-system-function 'select-utf-8-or-raw)) > (save-buffer)))) Thanks!!! This gets me started. ~K