nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
917 stars 44 forks source link

Want transclusion filter ,but failed. #192

Closed sincebyte closed 1 year ago

sincebyte commented 1 year ago

Want transclusion filter ,but failed.

the org mode code:

#+transclude: [[file:abc.java]] :lines 1-2 :src  java

doom emacs config :

(add-to-list 'load-path "/Users/van/.emacs.d/.local/straight/repos/org-transclusion")
(use-package! org-transclusion-src-lines)
(use-package! org-transclusion
  :after org
  :init
  (map!
   :leader
   :prefix "n"
   :desc "Org Transclusion Mode" "t" #'org-transclusion-mode
   :desc "org-transclusion-refresh" "g" #'org-transclusion-refresh))

the error:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  insert(nil)
  (progn (progn (make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t)) (org-mode))) (insert path) (org-element-context))
  (unwind-protect (progn (progn (make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t)) (org-mode))) (insert path) (org-element-context)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (progn (make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t)) (org-mode))) (insert path) (org-element-context)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (progn (make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t)) (org-mode))) (insert path) (org-element-context)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  org-transclusion-wrap-path-to-link(nil)
  (let* ((keyword-plist (org-transclusion-keyword-string-to-plist)) (link (org-transclusion-wrap-path-to-link (plist-get keyword-plist :link))) (payload (run-hook-with-args-until-success 'org-transclusion-add-functions link keyword-plist)) (tc-type (plist-get payload :tc-type)) (src-buf (plist-get payload :src-buf)) (src-beg (plist-get payload :src-beg)) (src-end (plist-get payload :src-end)) (src-content (plist-get payload :src-content))) (if (or (string= src-content "") (eq src-content nil)) (progn (message (format "No content found with \"%s\".  Check the link at poi..." (org-element-property :raw-link link) (point) (org-current-line)) nil)) (let ((beg (line-beginning-position)) (end)) (let* ((modified (buffer-modified-p)) (inhibit-read-only t)) (unwind-protect (progn (if (save-excursion ... ... ... ... ... t) (progn ...))) (if modified nil (restore-buffer-modified-p nil)))) (run-hook-with-args 'org-transclusion-after-add-functions beg end)) t))
  (progn (if org-transclusion-mode nil (let ((org-transclusion-add-all-on-activate nil)) (org-transclusion-mode 1))) (let* ((keyword-plist (org-transclusion-keyword-string-to-plist)) (link (org-transclusion-wrap-path-to-link (plist-get keyword-plist :link))) (payload (run-hook-with-args-until-success 'org-transclusion-add-functions link keyword-plist)) (tc-type (plist-get payload :tc-type)) (src-buf (plist-get payload :src-buf)) (src-beg (plist-get payload :src-beg)) (src-end (plist-get payload :src-end)) (src-content (plist-get payload :src-content))) (if (or (string= src-content "") (eq src-content nil)) (progn (message (format "No content found with \"%s\".  Check the link at poi..." (org-element-property :raw-link link) (point) (org-current-line)) nil)) (let ((beg (line-beginning-position)) (end)) (let* ((modified (buffer-modified-p)) (inhibit-read-only t)) (unwind-protect (progn (if ... ...)) (if modified nil (restore-buffer-modified-p nil)))) (run-hook-with-args 'org-transclusion-after-add-functions beg end)) t)))
  (if (org-transclusion-check-add) (progn (if org-transclusion-mode nil (let ((org-transclusion-add-all-on-activate nil)) (org-transclusion-mode 1))) (let* ((keyword-plist (org-transclusion-keyword-string-to-plist)) (link (org-transclusion-wrap-path-to-link (plist-get keyword-plist :link))) (payload (run-hook-with-args-until-success 'org-transclusion-add-functions link keyword-plist)) (tc-type (plist-get payload :tc-type)) (src-buf (plist-get payload :src-buf)) (src-beg (plist-get payload :src-beg)) (src-end (plist-get payload :src-end)) (src-content (plist-get payload :src-content))) (if (or (string= src-content "") (eq src-content nil)) (progn (message (format "No content found with \"%s\".  Check the link at poi..." (org-element-property :raw-link link) (point) (org-current-line)) nil)) (let ((beg (line-beginning-position)) (end)) (let* ((modified ...) (inhibit-read-only t)) (unwind-protect (progn ...) (if modified nil ...))) (run-hook-with-args 'org-transclusion-after-add-functions beg end)) t))))
  org-transclusion-add()
  (if (org-transclusion-add) (progn (message (format "Transcluded at point %d, line %d" (point) (org-current-line)))))
  (condition-case err (if (org-transclusion-add) (progn (message (format "Transcluded at point %d, line %d" (point) (org-current-line))))) ((debug error) (message "Not transcluded. Continue to next: %S" err) nil))
  (if (or (org-transclusion-within-transclusion-p) (plist-get (org-transclusion-keyword-string-to-plist) :disable-auto)) nil (condition-case err (if (org-transclusion-add) (progn (message (format "Transcluded at point %d, line %d" (point) (org-current-line))))) ((debug error) (message "Not transcluded. Continue to next: %S" err) nil)))
  (while (re-search-forward regexp nil t) (if (or (org-transclusion-within-transclusion-p) (plist-get (org-transclusion-keyword-string-to-plist) :disable-auto)) nil (condition-case err (if (org-transclusion-add) (progn (message (format "Transcluded at point %d, line %d" (point) (org-current-line))))) ((debug error) (message "Not transcluded. Continue to next: %S" err) nil))))
  (let ((regexp "^[ \11]*#\\+TRANSCLUDE:")) (while (re-search-forward regexp nil t) (if (or (org-transclusion-within-transclusion-p) (plist-get (org-transclusion-keyword-string-to-plist) :disable-auto)) nil (condition-case err (if (org-transclusion-add) (progn (message (format "Transcluded at point %d, line %d" ... ...)))) ((debug error) (message "Not transcluded. Continue to next: %S" err) nil)))))
  (let ((marker (move-marker (make-marker) (point)))) (if narrowed nil (widen)) (goto-char (point-min)) (let ((regexp "^[ \11]*#\\+TRANSCLUDE:")) (while (re-search-forward regexp nil t) (if (or (org-transclusion-within-transclusion-p) (plist-get (org-transclusion-keyword-string-to-plist) :disable-auto)) nil (condition-case err (if (org-transclusion-add) (progn (message ...))) ((debug error) (message "Not transcluded. Continue to next: %S" err) nil))))) (goto-char marker) (move-marker marker nil) t)
  (save-restriction (let ((marker (move-marker (make-marker) (point)))) (if narrowed nil (widen)) (goto-char (point-min)) (let ((regexp "^[ \11]*#\\+TRANSCLUDE:")) (while (re-search-forward regexp nil t) (if (or (org-transclusion-within-transclusion-p) (plist-get (org-transclusion-keyword-string-to-plist) :disable-auto)) nil (condition-case err (if (org-transclusion-add) (progn ...)) ((debug error) (message "Not transcluded. Continue to next: %S" err) nil))))) (goto-char marker) (move-marker marker nil) t))
  org-transclusion-add-all()
  (progn (org-transclusion-add-all))
  (if org-transclusion-add-all-on-activate (progn (org-transclusion-add-all)))
  (cond (org-transclusion-mode (org-transclusion-activate) (if org-transclusion-add-all-on-activate (progn (org-transclusion-add-all)))) (t (org-transclusion-deactivate)))
  (let ((last-message (current-message))) (setq org-transclusion-mode (cond ((eq arg 'toggle) (not org-transclusion-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'org-transclusion-mode local-minor-modes)) (if org-transclusion-mode (progn (setq local-minor-modes (cons 'org-transclusion-mode local-minor-modes)))))) (cond (org-transclusion-mode (org-transclusion-activate) (if org-transclusion-add-all-on-activate (progn (org-transclusion-add-all)))) (t (org-transclusion-deactivate))) (run-hooks 'org-transclusion-mode-hook (if org-transclusion-mode 'org-transclusion-mode-on-hook 'org-transclusion-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "Org-Transclusion mode %sabled%s" (if org-transclusion-mode "en" "dis") local))))))
  org-transclusion-mode(toggle)
  #<subr funcall-interactively>(org-transclusion-mode toggle)
  apply(#<subr funcall-interactively> (org-transclusion-mode toggle))
  funcall-interactively(org-transclusion-mode toggle)
  #<subr call-interactively>(org-transclusion-mode nil nil)
  apply(#<subr call-interactively> (org-transclusion-mode nil nil))
  explain-pause--wrap-call-interactively(#<subr call-interactively> org-transclusion-mode nil nil)
  apply(explain-pause--wrap-call-interactively #<subr call-interactively> (org-transclusion-mode nil nil))
  call-interactively(org-transclusion-mode nil nil)
  command-execute(org-transclusion-mode)
nobiot commented 1 year ago

What does the java file look like?

sincebyte commented 1 year ago

Just some unmeanful text content, I throught the java file just as a normal text file no matter it's correct or not for java syntaxt right?

123
123
123
1234
nobiot commented 1 year ago

Thank you for the additional information. Your assumption about the java file and syntax is correct. I have reproduced the issue and patched it. As you are using doom, I think you’re getting the source from GitHub. If so, please try the latest commit in main. Please let us know if it works.

sincebyte commented 1 year ago

Thank you for the additional information. Your assumption about the java file and syntax is correct. I have reproduced the issue and patched it. As you are using doom, I think you’re getting the source from GitHub. If so, please try the latest commit in main. Please let us know if it works.

you guys are really efficient, it works!

nobiot commented 1 year ago

Thank you for confirming and coming back to close the issue :)