From: Harald Hanche-Olsen <hanche@math.ntnu.no>
To: help-gnu-emacs@gnu.org
Subject: Re: How to convert this macro to Elisp?
Date: Mon, 15 Feb 2010 21:05:38 -0500 [thread overview]
Message-ID: <pco4olij5ot.fsf@math.ntnu.no> (raw)
In-Reply-To: hlco57$9h6$1@reader2.panix.com
+ kj <no.email@please.post>:
> 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))))
A proper solution should probably use lower-level functions, however.
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
next prev parent reply other threads:[~2010-02-16 2:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-16 0:16 How to convert this macro to Elisp? kj
2010-02-16 2:05 ` Harald Hanche-Olsen [this message]
2010-02-16 14:27 ` kj
2010-02-16 13:07 ` Alberto Luaces
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pco4olij5ot.fsf@math.ntnu.no \
--to=hanche@math.ntnu.no \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.