(Emacs/elisp)~current work in org bookmark
This commit is contained in:
@@ -25,21 +25,45 @@
|
|||||||
|
|
||||||
(require 'org)
|
(require 'org)
|
||||||
|
|
||||||
(defvar +bookmark/file (expand-file-name "~/Text/bookmarks.org"))
|
(defvar +bookmark/file (expand-file-name (concat org-directory "/bookmarks.org")))
|
||||||
(defvar +bookmark/mpv-args "--ytdl-raw-options=force-ipv4= --ytdl-format=22")
|
(defvar +bookmark/mpv-args "--ytdl-raw-options=force-ipv4= --ytdl-format=22 -v")
|
||||||
|
|
||||||
|
(defun +bookmark/--extract-heading ()
|
||||||
|
(let ((heading-components (org-heading-components))
|
||||||
|
(tags (org-get-tags)))
|
||||||
|
(message "%s" tags)
|
||||||
|
(list
|
||||||
|
(nth 4 heading-components)
|
||||||
|
(cl-remove-if #'(lambda (tag) (string= tag "bookmark")) tags)
|
||||||
|
(substring-no-properties
|
||||||
|
(org-agenda-get-some-entry-text
|
||||||
|
(point-marker)
|
||||||
|
most-positive-fixnum)))))
|
||||||
|
|
||||||
|
(defun +bookmark/--extract-all-heading-data ()
|
||||||
|
(cl-remove-if
|
||||||
|
#'(lambda (x) (member "DONE" (nth 1 x)))
|
||||||
|
(org-scan-tags
|
||||||
|
#'+bookmark/--extract-heading
|
||||||
|
(cdr (org-make-tags-matcher ":bookmark:"))
|
||||||
|
nil)))
|
||||||
|
|
||||||
|
(defun +bookmark/--heading->record (heading)
|
||||||
|
(cl-destructuring-bind (name tags url) heading
|
||||||
|
(cons
|
||||||
|
(concat name
|
||||||
|
" "
|
||||||
|
(substring-no-properties
|
||||||
|
(cl-reduce #'(lambda (x y) (concat x ":" y))
|
||||||
|
tags
|
||||||
|
:initial-value "")))
|
||||||
|
url)))
|
||||||
|
|
||||||
(defun +bookmark/bookmarks ()
|
(defun +bookmark/bookmarks ()
|
||||||
(with-current-buffer (find-file-noselect +bookmark/file)
|
(with-current-buffer (find-file-noselect +bookmark/file)
|
||||||
(org-scan-tags
|
(mapcar
|
||||||
#'(lambda nil
|
#'+bookmark/--heading->record
|
||||||
(let ((heading-components (org-heading-components)))
|
(+bookmark/--extract-all-heading-data))))
|
||||||
(cons
|
|
||||||
(concat (nth 4 heading-components) (nth 5 heading-components))
|
|
||||||
(substring-no-properties (org-agenda-get-some-entry-text
|
|
||||||
(point-marker)
|
|
||||||
most-positive-fixnum)))))
|
|
||||||
(cdr (org-make-tags-matcher ":bookmark:"))
|
|
||||||
nil)))
|
|
||||||
|
|
||||||
(defun +bookmark/open-bookmark ()
|
(defun +bookmark/open-bookmark ()
|
||||||
(interactive)
|
(interactive)
|
||||||
@@ -62,12 +86,7 @@
|
|||||||
(comint-mode))
|
(comint-mode))
|
||||||
(set-process-filter (start-process-shell-command
|
(set-process-filter (start-process-shell-command
|
||||||
"bookmark-mpv" "*mpv*"
|
"bookmark-mpv" "*mpv*"
|
||||||
(concat
|
(concat "mpv " +bookmark/mpv-args " \"" (cdr pair) "\""))
|
||||||
"mpv "
|
|
||||||
+bookmark/mpv-args
|
|
||||||
" \""
|
|
||||||
(cdr pair)
|
|
||||||
"\""))
|
|
||||||
#'comint-output-filter))
|
#'comint-output-filter))
|
||||||
(t
|
(t
|
||||||
(message "[bookmark]: Starting eww")
|
(message "[bookmark]: Starting eww")
|
||||||
|
|||||||
Reference in New Issue
Block a user