help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to "asciify" a string?


From: Tak Kunihiro
Subject: Re: Is there a way to "asciify" a string?
Date: Mon, 28 May 2018 14:24:13 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (windows-nt)

Teemu Likonen <tlikonen@iki.fi> writes:

>     (defun my-ascii-normalize-filter (string)
>       (require 'cl-lib)
>       (cl-remove-if (lambda (char)
>                       (> char 127))
>                     (ucs-normalize-NFKD-string string)))

It is cool. I wanted to asciify the name too.  
I put the code into my M-l as shown below.

#+BEGIN_SRC emacs-lisp
(defun downcase-or-normalize-word (arg)
  "Convert to lower case from point to end of word, moving over.
With ARG, normalize a word on point, moving over."
  (interactive "p")
  (require 'cl-lib)
  (if (equal arg 4)
      (let ((point0 (point)) string)
        (forward-word 1)
        (setq string (buffer-substring point0 (point)))
        (delete-region point0 (point))
        (insert
         (cl-remove-if (lambda (char)
                         (> char 127))
                       (ucs-normalize-NFKD-string string))))
    (downcase-word arg)))

(global-set-key [remap downcase-word] 'downcase-or-normalize-word)
#+END_SRC



reply via email to

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