Grab current line in buffer as a string in elisp

孤街浪徒 提交于 2019-12-20 11:28:10

问题


How can i collect the buffer's current line as a string value in elisp? i can do this,

(let (p1 p2 myLine)
 (setq p1 (line-beginning-position) )
  (setq p2 (line-end-position) )
  (setq myLine (buffer-substring-no-properties p1 p2))
)

but is there anyway i can do it in one line as,

(with-current-buffer get-current-line)

回答1:


Use thing-at-point:

(thing-at-point 'line t)

but note that this also returns any newline at the end of the line.



来源:https://stackoverflow.com/questions/27995488/grab-current-line-in-buffer-as-a-string-in-elisp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!