首页 > 解决方案 > 更改 Org-mode Mind-Map 中的节点属性

问题描述

尝试修改org-mind-map以更改节点和边的属性。我还没有真正了解 emacs 和 org-mode 的内部结构,并“按原样”使用它们——没有进行修改,因此并不真正理解。因此,如果可以解释自定义选项的含义以及如何在 org 文件中实现它们,那就太好了。这也将帮助我处理其他组织模式文件。我什至不知道如何正确地调用这个问题,否则我会用谷歌来解决这个问题。

因此,举个例子,如果我想将节点的“形状”更改为仅针对特定标题的“圆形”,那么该属性应该写在 org 文件的标题中的什么位置?因此,在从主项目中获取的示例中,这是可行的。

* This is an org-mode tree with tags
:PROPERTIES:
:OMM-COLOR: GREEN
:OMM-LEGEND: Legend entry
:END:

要更改节点的形状,文档中提到了使用 :OMM-NODE-FMT 和一些关于自定义选项的内容。

;;; Customizable Options:
;; Below is a list of customizable options:

;;  `org-mind-map-default-node-attribs'
;;    Alist of default node attributes and values.
;;    default = '(("shape" . "plaintext"))

;; You can customize the style of the graph by adding :OMM-NODE-FMT and :OMM-EDGE-FMT properties
;; to the headlines in the tree.

在代码中,文档告诉我们,

(defcustom org-mind-map-default-node-attribs '(("shape" . "plaintext"))
  "Alist of default node attributes and values.
Each item in the alist should be a cons cell of the form (ATTRIB . VALUE)
where ATTRIB and VALUE are strings.
For a list of value attributes, see here: https://graphviz.gitlab.io/_pages/doc/info/attrs.html"
  :type '(alist :key-type (string :tag "Attribute") :value-type (string :tag " Value"))
  :group 'org-mind-map)

那么,对于 org-mode 中的标题,如果我想更改节点的形状,我应该将这些选项放在哪里?我应该做这样的事情吗

* This is an org-mode tree with tags
:PROPERTIES:
:OMM-NODE-FMT: '(("shape" . "circle"))
:OMM-COLOR: GREEN
:OMM-LEGEND: Legend entry
:END:

这当然行不通。请帮忙!

标签: emacsorg-mode

解决方案


要使用:OMM-NODE-FMT::OMM-EDGE-FMT:您实际上必须创建一个函数并将其org-mind-map-node-formats分别添加到org-mind-map-node-formats.

幸运的是,有一些预定义的辅助宏可以使这尽可能简单:

  • 对于节点:(org-mind-map-make-node-fn NAME DOC PROPS &optional SHAPE COLOR OTHER)
  • 对于边缘:(org-mind-map-make-edge-fn NAME DOC PROPS &optional STYLE COLOR OTHER)

不幸的是,在对 org-mind-map 进行一些更改后,节点一似乎没有更新,因此只能通过一些变通方法使用(见下文)。我在 github 页面上创建了一个新问题。org-mind-map的所有者很久没有在github上活跃了,所以这个问题可能不会解决。

这就是你的做法:

:OMM-节点-FMT:

(require 'ox-org)
(org-mind-map-make-node-fn circle "circle shape" nil "circle" nil nil)
;; until fixed: wrap inside a lambda.
(add-to-list 'org-mind-map-node-formats
             '("circle" . (lambda (title tags color hm el &optional content images)
                            (org-mind-map-circle-node title tags color hm el))))

检查文档org-mind-map-make-node-fn以获取有关参数的更多信息。

然后使用如下:

* circle
:PROPERTIES:
:OMM-NODE-FMT: circle
:END:

** rectangle

结果:

具有圆形和矩形形状的思维导图

:OMM-EDGE-FMT:

这将是这样做的方法,但它不起作用(在 github 页面上创建了另一个问题):

(require 'ox-org)
(org-mind-map-make-edge-fn dashed "dashed, red and empty arrowhead"
                           nil "dashed" "red" "arrowhead=empty")
(add-to-list 'org-mind-map-edge-formats
             '("dashed" . org-mind-map-dashed-edge))

即使改变(setq org-mind-map-edge-format-default "[style=dotted]")也没有效果。

全局更改边缘样式的唯一方法是修改(setq org-mind-map-default-edge-attribs '(("style" . "dotted"))).


推荐阅读