2025-06-24-09-18

43 阅读1分钟
#+name: remap-id-link
#+begin_src emacs-lisp :eval no
  (catch 'found
    ;; id links
    (setq links (gethash link id->ids))
    (dolist (l links)
      (setq l (string-trim
               l "\\[\\[id:" "\\]\\]"))
      (funcall log "[%d]try %S..." nlv l)
      (when (ignore-errors
              ;; 这里,我们用是 advice 之
              ;; 后的 `org-id-open', 换
              ;; 言之,我们在这里递归调用自
              ;; 身,以实现递归重映射,即:
              ;; id1 -> id2 -> id3 ...
              (funcall 'org-id-open
                       l _ (1+ nlv))
              t)
        (funcall log "[%d]%S remap to %S"
                 nlv link l)
        (throw 'found t))))
#+end_src