如何使用elisp更改缓冲区中的单词? [英] How can I change a word in a buffer using elisp?
本文介绍了如何使用elisp更改缓冲区中的单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用elisp更改单词?类似于(大写单词)但使用我自己的函数?
How can I change the word at point using elisp? Something quite like (upcase-word) but using my own function?
背景:我编写了一个函数,该函数可以检测点的底数并可以将其转换到其他任何基地。我想做的就是直接在缓冲区中更改数字。
Background: I've written a function that detects the base of the number at point and can convert it to any other base. What I would like to do is to change the number directly in the buffer.
TIA
Markus
TIA Markus
推荐答案
尝试此代码。我包括了一个使用 upcase
的示例交互功能:
Try this code. I've included a sample interactive function using upcase
:
(defun change-word-at-point (fun)
(cl-destructuring-bind (beg . end)
(bounds-of-thing-at-point 'word)
(let ((str (buffer-substring-no-properties beg end)))
(delete-region beg end)
(insert (funcall fun str)))))
(defun upcase-word ()
(interactive)
(change-word-at-point 'upcase))
这篇关于如何使用elisp更改缓冲区中的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文