소스 검색

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 년 전
부모
커밋
6c88d8e406
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  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.