Emacs 组织模式:select 最后一个词,在其上插入 link
Emacs org-mode: select last word, insert link onto it
我想编写一个 emacs lisp 函数来选择最后一个词并将其link发送到 kill ring 中的最后一项。我写了以下内容:
(defun link-last-word-from-kill ()
(interactive)
(push-mark)
(backward-word)
(org-insert-link 0 (yank) (buffer-substring (region-beginning) (region-end)))
(pop-mark)
)
我不确定我是否正确阅读 (org-insert-link &optional COMPLETE-FILE LINK-LOCATION DESCRIPTION)
;我想我已经将 link 位置设置为 kill-ring,但系统仍然提示我输入 link。我误会了什么?
我认为 yank 使用缓冲区作为输出。您还需要用 link 替换之前的单词。我选择只使用标记创建组织模式 link,例如:[[http://foo.invalid][PreviousWordHere]]
(defun link-last-word-from-kill ()
(interactive)
(push-mark)
(backward-word)
(insert "[[")
(yank)
(insert "][")
(forward-word)
(insert "]]")
(pop-mark))
我想编写一个 emacs lisp 函数来选择最后一个词并将其link发送到 kill ring 中的最后一项。我写了以下内容:
(defun link-last-word-from-kill ()
(interactive)
(push-mark)
(backward-word)
(org-insert-link 0 (yank) (buffer-substring (region-beginning) (region-end)))
(pop-mark)
)
我不确定我是否正确阅读 (org-insert-link &optional COMPLETE-FILE LINK-LOCATION DESCRIPTION)
;我想我已经将 link 位置设置为 kill-ring,但系统仍然提示我输入 link。我误会了什么?
我认为 yank 使用缓冲区作为输出。您还需要用 link 替换之前的单词。我选择只使用标记创建组织模式 link,例如:[[http://foo.invalid][PreviousWordHere]]
(defun link-last-word-from-kill ()
(interactive)
(push-mark)
(backward-word)
(insert "[[")
(yank)
(insert "][")
(forward-word)
(insert "]]")
(pop-mark))