From ce3beed94d47b4f2013bfccadb57abe69a8a7771 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Sun, 24 May 2020 19:10:49 +0800 Subject: [PATCH] Enhance eaf-org to support all applications (#301) * make eaf-pdf-outline buffer read-only and bind "q" to close window * create new file eaf-org.el * Fix #279 Integrate with Org Mode Support org-store-link and org-link-open. Currently supported application is pdf-viewer only. * remove old comments * support all applications * consider the case that `extra-args` is nil * support js-video-player application and jump to timestamp Co-authored-by: Andy Stewart --- README.md | 9 +++++++-- README.zh-CN.md | 6 ++++++ eaf-org.el | 18 +++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 971c30d..51f51e2 100644 --- a/README.md +++ b/README.md @@ -204,8 +204,13 @@ Enable with (require 'eaf-org) ``` -- Support `org-store-link` and `org-link-open` - - Currently only support pdf-viewer app. +Support `org-store-link` and `org-link-open` mechanism. + +Currently support following applications: + +- pdf-viewer support jump to page number +- js-video-player support jump to video timestamp +- on theory supports all EAF applications without extra argument which has `eaf--buffer-url` ## EAF in the community diff --git a/README.zh-CN.md b/README.zh-CN.md index 2bba1f9..5049bcb 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -201,6 +201,12 @@ eaf-evil 会动态查询 eaf 应用的按键绑定, 使得 evil 在 normal 模 (require 'eaf-org) ``` +当前支持如下应用: + +- pdf-viewer 跳转到记录的标记页面 +- js-video-player 跳转到记录的视频时间戳 +- 理论上支持所有EAF应用(只要应用有 `eaf--buffer-url` 参数值) + ## EAF社区 下面列表列展示了EAF在Emacs社区的应用。如果我们遗漏你的应用,欢迎提交PR来加到下面列表中。 diff --git a/eaf-org.el b/eaf-org.el index a0a27ab..b620366 100644 --- a/eaf-org.el +++ b/eaf-org.el @@ -47,9 +47,12 @@ The raw link looks like this: [[eaf:::::]]" (url eaf--buffer-url) (extra-args (cl-case (intern app) ('pdf-viewer - (eaf-call "call_function" eaf--buffer-id "current_page")))) - ;; (eaf-call "call_function_with_args" eaf--buffer-id "store_session_data" (format "%s" page-num)) - (link (concat "eaf:" app "::" url "::" extra-args)) + (eaf-call "call_function" eaf--buffer-id "current_page")) + ('js-video-player + (eaf-call "call_function" eaf--buffer-id "save_session_data")))) + (link (if extra-args + (concat "eaf:" app "::" url "::" extra-args) + (concat "eaf:" app "::" url))) (description (buffer-name))) (org-link-store-props :type "eaf" @@ -64,10 +67,15 @@ The raw link looks like this: [[eaf:::::]]" (extra-args (caddr list))) (cl-case app ('pdf-viewer - ;; TODO open the PDF file (eaf-open url "pdf-viewer") (eaf-call "call_function_with_args" eaf--buffer-id - "jump_to_page_with_num" (format "%s" extra-args)))))) + "jump_to_page_with_num" (format "%s" extra-args))) + ('js-video-player + (eaf-open url "js-video-player") + (eaf-call "call_function_with_args" eaf--buffer-id + "restore_session_data" (format "%s" extra-args))) + (t + (eaf-open url))))) (org-link-set-parameters "eaf" :follow #'eaf-org-open