emacs 如何复制光标下的链接

Org 中的链接会渲染成如下情况

image

我现在复制光标下的链接用的是 C-c C-l,然后 C-x h + M-w

不知道有没有更方便的命令,还是像 获取光标所在字符串的方法? 自己写一个?

;; From https://www.reddit.com/r/emacs/comments/erro41/weekly_tipstricketc_thread/
(defun org-copy-entire-link-at-point ()
  "Save the link at point in the kill ring."
  (interactive)
  (when (org-in-regexp org-link-bracket-re 1)
    (kill-ring-save (match-beginning 0) (match-end 0))
    (message "%s" (car kill-ring))))

(defun org-with-link (fn)
  "Call function FN with the target of the link at point to the kill ring."
  (if-let* ((link (when (org-in-regexp org-bracket-link-regexp)
                    (org-link-unescape (match-string-no-properties 1)))))
      (funcall fn link)
    (user-error "Not in a link.")))

(defun org-copy-link-at-point ()
  "Copy the target of the link at point to the kill ring."
  (interactive)
  (org-with-link (lambda (link)
                   (kill-new link)
                   (message "%s" link))))
2 个赞

已经很方便了,你还希望怎么方便?

如果什么都想着【一键】完成,恐怕 1000 键的键盘也不够用。

1 个赞

感觉这个人像是玩 爵士鼓的。

咋一看以为什么高科技