emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-remark 31b4971b97 6/6: feat(module): create link to


From: ELPA Syncer
Subject: [elpa] externals/org-remark 31b4971b97 6/6: feat(module): create link to source other than file:
Date: Fri, 23 Dec 2022 10:57:56 -0500 (EST)

branch: externals/org-remark
commit 31b4971b97c33f1e358296a1961f120c34e3a7fd
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>

    feat(module): create link to source other than file:
---
 org-remark-eww.el             | 21 +++++++++++++++------
 org-remark-global-tracking.el | 11 ++++++++---
 org-remark.el                 |  6 ++----
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/org-remark-eww.el b/org-remark-eww.el
index 552412d25b..dd95ee935d 100644
--- a/org-remark-eww.el
+++ b/org-remark-eww.el
@@ -37,18 +37,27 @@
 (require 'eww)
 ;; Silence compiler
 (defvar org-remark-global-tracking-mode)
+(declare-function org-remark-auto-on "org-remark-global-tracking")
 
-(defun org-remark-eww-global-tracking-mode ()
+(defun org-remark-eww-enable ()
   (if org-remark-global-tracking-mode
       (add-hook 'eww-after-render-hook #'org-remark-auto-on)
     (remove-hook 'eww-after-render-hook #'org-remark-auto-on))
-  (add-to-list 'org-remark-source-find-file-name-functions
-               #'org-remark-eww-find-file-name))
+  ;; TODO allow for disable with org-remark-mode-hook (local)
+  (add-hook 'org-remark-source-find-file-name-functions
+            #'org-remark-eww-find-file-name)
+  (add-hook 'org-remark-highlight-link-to-source-functions
+            #'org-remark-eww-highlight-link-to-source))
 
 (defun org-remark-eww-find-file-name ()
-  (if (eq major-mode 'eww-mode)
-      (let ((url-parsed (url-generic-parse-url (eww-current-url))))
-        (concat (url-host url-parsed) (url-filename url-parsed)))))
+  (when (eq major-mode 'eww-mode)
+    (let ((url-parsed (url-generic-parse-url (eww-current-url))))
+      (concat (url-host url-parsed) (url-filename url-parsed)))))
+
+(defun org-remark-eww-highlight-link-to-source (filename)
+  (when (eq major-mode 'eww-mode)
+    ;;; FIXME we shhould not assume https?
+    (concat "[[https://"; filename "]]")))
 
 (provide 'org-remark-eww)
 ;;; org-remark-eww.el ends here
diff --git a/org-remark-global-tracking.el b/org-remark-global-tracking.el
index 68a2426cb6..bdb288ccf3 100644
--- a/org-remark-global-tracking.el
+++ b/org-remark-global-tracking.el
@@ -93,8 +93,13 @@ appropriate function to this hook.
 Assume that the current buffer is the source buffer when the function is
 called, which can be used to find the file name."
   :group 'org-remark
-  :type
-  '(repeat function))
+  :type '(repeat function))
+
+(defcustom org-remark-highlight-link-to-source-functions nil
+  "Abnormal hook called to create a link to source in notes file.
+Each one is called with FILENAME as an argument."
+  :group 'org-remark
+  :type '(repeat function))
 
 (defun org-remark-modules-set (symbol value)
   "Enable the modules set in user option `org-remark-modules'.
@@ -104,7 +109,7 @@ Set SYMBOL and VALUE for `org-remark-modules'."
     (let ((feat (intern (concat "org-remark-" (symbol-name module))))
           (fn (intern (concat "org-remark-"
                      (symbol-name module)
-                     "-global-tracking-mode"))))
+                     "-enable"))))
       (require feat)
       (when (functionp fn)
         ;; As minor mode would have been already activated, run the
diff --git a/org-remark.el b/org-remark.el
index 59e02a74e2..c2c277bd62 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -777,10 +777,8 @@ source with using ORGID."
          (link (if buffer-file-name
                    (concat "[[file:" filename
                            (when line-num (format "::%d" line-num)) "]]")
-                 ;;FIXME we really should not assume EWW
-                 (when (eq major-mode 'eww-mode)
-                   ;;; FIXME we shhould not assume https?
-                   (concat "[[https://"; filename "]]")))))
+                 (run-hook-with-args-until-success
+                  'org-remark-highlight-link-to-source-functions filename))))
     (with-current-buffer notes-buf
       (when (featurep 'org-remark-convert-legacy) 
(org-remark-convert-legacy-data))
       ;;`org-with-wide-buffer is a macro that should work for non-Org file'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]