组织模式:使链接在列视图中可点击?

发布于 2024-12-11 04:53:53 字数 555 浏览 0 评论 0原文

我尝试制作一些 org 文件来在 emacs 中组织我的内容,但我不太明白如何在 列视图

目前,我的组织文件如下所示:

* Main
:PROPERTIES:
:COLUMNS: %10ITEM %20LINK
:END:
** SUB1
:PROPERTIES:
:LINK: [[foo][bar]]
:END:
** SUB2
:PROPERTIES:
:LINK: [[bar][foo]]
:END:

但是,我在列视图中得到的不是可点击的链接,而是类似的内容:

  ITEM     | LINK         |
* Main     |              |
** SUB1    |[[foo][bar]]  |
** SUB2    |[[bar][foo]]  |

有没有办法使列视图像组织模式中的其他地方一样显示可点击的链接?

I tried to make some org file to organize my thing in emacs, but I can't quite get how to make a clickable link in column view.

Currently, my org file looks like this:

* Main
:PROPERTIES:
:COLUMNS: %10ITEM %20LINK
:END:
** SUB1
:PROPERTIES:
:LINK: [[foo][bar]]
:END:
** SUB2
:PROPERTIES:
:LINK: [[bar][foo]]
:END:

However, instead of clickable link, I got something like this in column view:

  ITEM     | LINK         |
* Main     |              |
** SUB1    |[[foo][bar]]  |
** SUB2    |[[bar][foo]]  |

Is there any way to make column view show a clickable link like elsewhere in Org mode?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

So尛奶瓶 2024-12-18 04:53:53

组织模式9.6.7

搜索标签xxx,带有链接:

#+BEGIN: columnview :id local :match "xxx" :format "%ITEM(Title) %ID(Link)"
| Title | Link |                  |
|-------+------+------------------|
| Help  | 7EB  | [[id:7EB][Link]] |
#+TBLFM: $3='(format "\[[id:%s][Link]\]" $2)
#+END: columnview

Org mode 9.6.7

Searching for tags xxx, with links:

#+BEGIN: columnview :id local :match "xxx" :format "%ITEM(Title) %ID(Link)"
| Title | Link |                  |
|-------+------+------------------|
| Help  | 7EB  | [[id:7EB][Link]] |
#+TBLFM: $3='(format "\[[id:%s][Link]\]" $2)
#+END: columnview
北音执念 2024-12-18 04:53:53

我是否误解了您的问题,或者您的 .emacs.d 中是否有任何特殊的组织模式配置,我使用 emacs -Q 打开您的组织模式文件,以及所有链接是可点击的。

~ » emacs --version                                                                                                                                                                                                                                                       
GNU Emacs 28.0.91

输入图片此处描述

Did I misunderstand your problem or is there any sepecial org-mode configuration in your .emacs.d, I open your org-mode file with emacs -Q, and all links are clickable.

~ » emacs --version                                                                                                                                                                                                                                                       
GNU Emacs 28.0.91

enter image description here

心房的律动 2024-12-18 04:53:53

我不知道当时情况是否有所不同,但在最近的 Org 模式版本(我使用的是 9.6)中,这很容易实现。

已经有命令org-columns-open-link,默认情况下绑定到列视图中的Cc Co,用于打开链接。因此,要使所有链接都可单击,只需:

(org-defkey org-columns-map [mouse-1] #'org-columns-open-link)

然而,每当单击非链接(例如更改点)时,都会显示一条用户错误消息。

为了获得更好的用户体验,我们可以自定义 org-columns-modify-value-for-display-function,如下所示:

(defun my-column-display-value-transformer (column-title value)
  "Modifies the value to display in column view."
  (when (and (string-prefix-p "[[" value)
             (string-suffix-p "]]" value))
    (string-match org-link-bracket-re value)
    (let ((target (match-string 1 value))
          (descr (match-string 2 value)))
      (setq value (or descr target))
      ;; put the suitable faces:
      (put-text-property 0 (length value) 'face 'org-link value)
      (put-text-property 0 (length value) 'mouse-face 'highlight value)
      ;; help echo:
      (put-text-property 0 (length value) 'help-echo
                         (format "LINK: %s" target) value)
      ;; put a local keymap:
      (put-text-property 0 (length value) 'keymap
                         '(keymap (mouse-1 . org-columns-open-link)) value)
      value)))

(setq org-columns-modify-value-for-display-function
      #'my-column-display-value-transformer)

可以通过检查 来检查该点的文本属性是否按预期设置>(get-char-property (point) 'org-columns-value) 在列视图中。

I don't know whether things were different back then, but in more recent Org mode versions (I'm on 9.6) this is quite easy to achieve.

There is already the command org-columns-open-link, which by default is bound to C-c C-o in column view, that does open links. Hence to make all links clickable one simply has to:

(org-defkey org-columns-map [mouse-1] #'org-columns-open-link)

This will however show a user-error message whenever clicking on a non-link (e.g. to change point).

To get a nicer user experience one can instead customize org-columns-modify-value-for-display-function as follows:

(defun my-column-display-value-transformer (column-title value)
  "Modifies the value to display in column view."
  (when (and (string-prefix-p "[[" value)
             (string-suffix-p "]]" value))
    (string-match org-link-bracket-re value)
    (let ((target (match-string 1 value))
          (descr (match-string 2 value)))
      (setq value (or descr target))
      ;; put the suitable faces:
      (put-text-property 0 (length value) 'face 'org-link value)
      (put-text-property 0 (length value) 'mouse-face 'highlight value)
      ;; help echo:
      (put-text-property 0 (length value) 'help-echo
                         (format "LINK: %s" target) value)
      ;; put a local keymap:
      (put-text-property 0 (length value) 'keymap
                         '(keymap (mouse-1 . org-columns-open-link)) value)
      value)))

(setq org-columns-modify-value-for-display-function
      #'my-column-display-value-transformer)

One can check whether the text properties at point are set as expected by exaluating (get-char-property (point) 'org-columns-value) in column view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文