问题
Trying to modify org-mind-map to change the attributes of the nodes and edges. I haven't really learned the internals of emacs and org-mode, and use them "as is" - without making modifications, and therefore not really understanding. So, it would be great if one could explain what custom options means and how to implement them in a org file. This will help me work with other org-mode files also. I do not know how to even call this problem properly, otherwise I would have google-fu'd this.
So, as an example, if I want to change the "shape" of node to "circle" for only a particular heading, where should that property be written within the headline of the org file? So in the example taken from the main project, this works.
* This is an org-mode tree with tags
:PROPERTIES:
:OMM-COLOR: GREEN
:OMM-LEGEND: Legend entry
:END:
To change the shape of the node, the documentation mentions using :OMM-NODE-FMT and something about custom options.
;;; 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.
And in the code the documentation tells us,
(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)
So, for a headline in org-mode if I want to change the shape of the node, where should I put those options? Should I do something like this
* This is an org-mode tree with tags
:PROPERTIES:
:OMM-NODE-FMT: '(("shape" . "circle"))
:OMM-COLOR: GREEN
:OMM-LEGEND: Legend entry
:END:
This isn't working, of course. Please help!
回答1:
To use :OMM-NODE-FMT:
and :OMM-EDGE-FMT:
you actually have to create a
function and add it to org-mind-map-node-formats
respectively org-mind-map-node-formats
.
Fortunately there are some auxiliary macros predefined to make this as easy as possible:
- for node:
(org-mind-map-make-node-fn NAME DOC PROPS &optional SHAPE COLOR OTHER)
- for edge:
(org-mind-map-make-edge-fn NAME DOC PROPS &optional STYLE COLOR OTHER)
Unfortunately the node one seems to not have been updated after some changes to org-mind-map and is therefore only useable with a little workaround (see below). I created a new issue on the github page. The owner of org-mind-map has not been active on github for a long time, so this will probably not be resolved.
This is how you do it:
:OMM-NODE-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))))
Check the documentation for org-mind-map-make-node-fn
to get more infos about the arguments.
Then use as follows:
* circle
:PROPERTIES:
:OMM-NODE-FMT: circle
:END:
** rectangle
Result:
:OMM-EDGE-FMT:
This would be the way to do it, but it's not working (created another issue on the github page):
(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))
Even changing (setq org-mind-map-edge-format-default "[style=dotted]")
has no
effect.
Only way to change edge style globally is by modifying (setq
org-mind-map-default-edge-attribs '(("style" . "dotted")))
.
来源:https://stackoverflow.com/questions/59021004/change-the-node-attributes-in-org-mode-mind-map