yuchen-lea / org-media-note

Taking interactive notes when watching videos or listening to audios in org-mode.
GNU General Public License v3.0
242 stars 35 forks source link

adjust timestamp functionality depends on org-link-edit.el and I did not know that, here's how I fixed it #48

Closed pedro-nonfree closed 10 months ago

pedro-nonfree commented 10 months ago

When I tried to make it work the (GREAT!!!) functionality of org-media-note-adjust-timestamp-offset it failed because function (org-link-edit--link-data) [1] was not defined

Then I discovered that I just needed this piece of code [2] which I got it from here [3], and this is by the way the proper place according to [4], you might want to get all the package, but I just needed that two functions to make the "adjust timestamp" functionality to work

I am just reporting how I solved the problem, I don't know how this should be fixed, just updating README.md docs? code refactor? code inclusion?

[1] https://github.com/yuchen-lea/org-media-note/blob/fa285dd59ccd9cd0b1823496293f17ab74569274/org-media-note-core.el#L490

[2] emacs lisp code:

(defun org-link-edit--on-link-p (&optional element)
  (org-element-lineage (or element (org-element-context)) '(link) t))

(defun org-link-edit--link-data ()
  "Return list with information about the link at point.
The list includes
- the position at the start of the link
- the position at the end of the link
- the link text
- the link description (nil when on a plain link)"
  (let ((el (org-element-context)))
    (unless (org-link-edit--on-link-p el)
      (user-error "Point is not on a link"))
    (save-excursion
      (goto-char (org-element-property :begin el))
      (cond
       ;; Use match-{beginning,end} because match-end is consistently
       ;; positioned after ]], while the :end property is positioned
       ;; at the next word on the line, if one is present.
       ((looking-at org-link-bracket-re)
        (list (match-beginning 0)
              (match-end 0)
              (save-match-data
                (org-link-unescape (match-string-no-properties 1)))
              (or (match-string-no-properties 2) "")))
       ((looking-at org-link-plain-re)
        (list (match-beginning 0)
              (match-end 0)
              (match-string-no-properties 0)
              nil))
       (t
        (error "What am I looking at?"))))))

[3] https://git.kyleam.com/org-link-edit/tree/org-link-edit.el?id=239179077ed8029bdccf7c9d4abcc6ea7d1aa2bb#n69

[4] release_0.4 commit message from https://git.sr.ht/~bzg/org-contrib/commit/c6aef31ccfc7c4418c3b51e98f7c3bd8e255f5e6 (I copy here the content too)

yuchen-lea commented 10 months ago

Thank you for pointing out this issue!

At that time, I lacked experience and mistakenly treated this function as a built-in. The latest commit should have fixed this issue. If there are any further problems, please let me know.