Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor fixes #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 67 additions & 35 deletions org-board.el
Original file line number Diff line number Diff line change
Expand Up @@ -691,33 +691,39 @@ added as a link in the `ARCHIVED_AT' property."

(interactive)
(org-board-expand-regexp-alist)
(let* ((attach-directory (org-attach-dir t))
(urls (org-entry-get-multivalued-property (point) "URL"))
(options
(org-board-options-handler
(org-entry-get-multivalued-property (point) "WGET_OPTIONS")))
(timestamp (org-board-make-timestamp))
(output-directory (concat (file-name-as-directory attach-directory)
(file-name-as-directory timestamp)))
(org-id-token (org-id-get))
(link-to-output (if (not org-board-make-relative)
(concat "[[file:" output-directory "]["
timestamp "]]")
(concat "[[file:" (file-relative-name output-directory)"][" timestamp "]]")))
(wget-process (org-board-wget-call org-board-wget-program
output-directory
options
urls)))
(process-put wget-process 'org-entry
(org-display-outline-path nil t "/" t))
(process-put wget-process 'wget-output-directory
output-directory)
(process-put wget-process 'org-id
org-id-token)
(process-put wget-process 'urls
(org-board-copy-list urls))
(org-entry-add-to-multivalued-property (point) "ARCHIVED_AT"
link-to-output)))
(save-mark-and-excursion
(save-window-excursion
(let* ((attach-directory (org-attach-dir t))
(urls (org-entry-get-multivalued-property (point) "URL"))
(options
(org-board-options-handler
(org-entry-get-multivalued-property (point) "WGET_OPTIONS")))
(timestamp (org-board-make-timestamp))
(output-directory (concat (file-name-as-directory attach-directory)
(file-name-as-directory timestamp)))
(org-id-token (org-id-get))
(link-to-output (if (not org-board-make-relative)
(concat "[[file:" output-directory "]["
timestamp "]]")
(concat "[[file:" (file-relative-name output-directory)"][" timestamp "]]")))
(wget-process (org-board-wget-call org-board-wget-program
output-directory
options
urls)))

(org-id-goto org-id-token)
(process-put wget-process 'org-entry
(org-display-outline-path nil t "/" t))
(process-put wget-process 'wget-output-directory
output-directory)
(process-put wget-process 'org-id
org-id-token)
(process-put wget-process 'urls
(org-board-copy-list urls))

(org-id-goto org-id-token)
charlesroelli marked this conversation as resolved.
Show resolved Hide resolved
(org-entry-add-to-multivalued-property (point) "ARCHIVED_AT"
link-to-output)))))

;;;###autoload
(defun org-board-archive-dry-run ()
Expand Down Expand Up @@ -854,24 +860,50 @@ non-nil."
;; or no argument and `eww' for `org-board-default-browser', try
;; to open the file in `eww' and return 0 (success), and if an
;; error occurs, throw it back to the user.
(if (or (and arg (eq org-board-default-browser 'system))
(and (not arg) (eq org-board-default-browser 'eww)))
(condition-case nil
(progn
(eww-open-file filename-string)
0)
(error 1))
(cond
((or (and arg (eq org-board-default-browser 'system))
(and (not arg) (eq org-board-default-browser 'eww)))
(condition-case nil
(progn
(eww-open-file filename-string)
0)
(error 1)))
;; If `org-board-default-browser' has been set to a function,
;; try calling that function, and on a failure continue down the cond.
;; Note: Relies on and not evaluating the second arg if the first is false.
((and (functionp org-board-default-browser)
(condition-case err
(progn
(funcall org-board-default-browser filename-string)
t)
(error (progn
(message "org-board-default-browser function failed: %s" err)
nil)))) 0)
;; If org-board-default-browser is a list of functions (i.e. (list #'eww)),
;; try them in order to see if any work, otherwise signal a failure.
((listp org-board-default-browser)
(do ((idx 0 (1+ idx)))
((>= idx (length org-board-default-browser)))
(let ((b (nth idx org-board-default-browser)))
(condition-case err
(progn
(funcall b filename-string)
(cl-return 0))
charlesroelli marked this conversation as resolved.
Show resolved Hide resolved
(error (progn
(message "%s failed: %s" b err)
1))))))
;; Otherwise, use `open' on a Mac, `xdg-open' on GNU/Linux and
;; BSD, and prompt for a shell command otherwise. (What would
;; be the best for Windows?) Return the exit code of the
;; process call.
(:else
(call-process (cond
((eq system-type 'darwin) "open")
((member system-type
'(gnu gnu/linux gnu/kfreebsd)) "xdg-open")
(t (read-shell-command "Open current file with: ")))
nil nil nil
filename-string))))
filename-string)))))

;;;###autoload
(defun org-board-extend-default-path (filename-string)
Expand Down