问题
I need to remove ascii character 0253 and add a carriage return in it's place. In emacs I do
M-x replace-string ý RET C-q C-j
C-q C-j adds a carriage return. I do this often enough that I creating a custom defun would be much better.
Here is what I have so far
(defun remove-253 ()
"Removes ASCII Character 0253 and adds a carriage return in it's place"
(interactive)
(replace-string "ý" .... not sure what to do next )
)
Your thoughts?
Thanks,
Norm
回答1:
This worked for me:
(replace-string "ý" "\n")
回答2:
`repeat-complex-command' (C-x escape escape) should also help you in future problems like this. It shows you the Emacs Lisp form that represents your last complex operation, so you can paste the form directly into a defun and off you go.
In this case, you would see:
(replace-string "ý" "\n" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
回答3:
Sounds like a job for keyboard macros. :-)
来源:https://stackoverflow.com/questions/7446913/how-to-define-an-emacs-command-that-uses-replace-string-to-replace-a-specific