Jelajahi Sumber

Fix multiple calls to `org-dynamic-block-alist'.

* lisp/org.el (org-dynamic-block-define): Update entry instead of
  piling up entries of the same type.
Nicolas Goaziou 6 tahun lalu
induk
melakukan
6c88d8e406
1 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 6 2
      lisp/org.el

+ 6 - 2
lisp/org.el

@@ -9593,8 +9593,12 @@ TYPE is the dynamic block type, as a string."
   (mapcar #'car org-dynamic-block-alist))
 
 (defun org-dynamic-block-define (type func)
-  "Define dynamic block TYPE with FUNC."
-  (push (cons type func) org-dynamic-block-alist))
+  "Define dynamic block TYPE with FUNC.
+TYPE is a string.  FUNC is the function creating the dynamic
+block of such type."
+  (pcase (assoc type org-dynamic-block-alist)
+    (`nil (push (cons type func) org-dynamic-block-alist))
+    (`(,def . ,_) (setcdr def func))))
 
 (defun org-dynamic-block-insert-dblock (type)
   "Insert a dynamic block of type TYPE.