获取光标所在字符串的方法?

本人耗尽毕生所学EmacsLisp,还有TG群的大佬指导写出来的函数,希望对你有帮助吧!可以获取当前光标下的字符串并且将其添加到kill环中。

(defun get-string (current-point)
  "获取当前光标下的字符串,并
CURRENT-POINT 是当前光标位点
BEFORE-QUOTATION 是前一个双引号的位置 LATER-QUOTAION则是后一个的位置"
  (interactive "d")
  (save-excursion
  (let ((before-quotation current-point)
        (later-quotation current-point))
    (if (search-forward "\"" nil t -1)
        (progn
          (setq before-quotation (point))
          (search-forward "\"" nil t 2)
          (setq later-quotation (point))
          (copy-region-as-kill before-quotation later-quotation))))))

get-string