From 6de34f2891ec736b28f46a3efa709435873298fd Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 18 May 2021 16:31:39 +0200 Subject: [PATCH] Move `org-file-url-p' to "org-macs.el", rename it to `org-url-p' * lisp/org-macs.el (org-url-p): New function. * lisp/org-compat.el (org-file-url-p): Make obsolete alias for function above. * lisp/org-lint.el (org-lint-non-existent-setupfile-parameter): * lisp/org.el (org--collect-keywords-1): (org-file-contents): (org-edit-special): Use new function. --- lisp/org-compat.el | 2 ++ lisp/org-lint.el | 2 +- lisp/org-macro.el | 1 - lisp/org-macs.el | 5 +++++ lisp/org.el | 12 +++--------- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 9da9cea6c..426f607b6 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -361,6 +361,8 @@ Counting starts at 1." (make-obsolete 'org-attach-store-link "No longer used" "9.4") (make-obsolete 'org-attach-expand-link "No longer used" "9.4") +(define-obsolete-function-alias 'org-file-url-p 'org-url-p "9.5") + (defun org-in-fixed-width-region-p () "Non-nil if point in a fixed-width region." (save-match-data diff --git a/lisp/org-lint.el b/lisp/org-lint.el index f537b0816..003fee0fa 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -593,7 +593,7 @@ in description" (let ((file (org-unbracket-string "\"" "\"" (org-element-property :value k)))) - (and (not (org-file-url-p file)) + (and (not (org-url-p file)) (not (file-remote-p file)) (not (file-exists-p file)) (list (org-element-property :begin k) diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 29c403658..c3fbce172 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -61,7 +61,6 @@ (declare-function org-element-type "org-element" (element)) (declare-function org-entry-get "org" (pom property &optional inherit literal-nil)) (declare-function org-file-contents "org" (file &optional noerror nocache)) -(declare-function org-file-url-p "org" (file)) (declare-function org-in-commented-heading-p "org" (&optional no-inheritance)) (declare-function org-link-search "ol" (s &optional avoid-pos stealth)) (declare-function org-mode "org" ()) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index f21baeb5b..77458db96 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -39,6 +39,7 @@ (declare-function org-string-collate-lessp "org-compat" (s1 s2 &optional locale ignore-case)) (defvar org-ts-regexp0) +(defvar ffap-url-regexp) ;;; Macros @@ -807,6 +808,10 @@ return nil." (list context (match-beginning group) (match-end group)) t))) +(defun org-url-p (s) + "Non-nil if string S is a URL." + (require 'ffap) + (string-match-p ffap-url-regexp s)) ;;; String manipulation diff --git a/lisp/org.el b/lisp/org.el index 0add9bc2e..0cd88d3eb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -191,7 +191,6 @@ Stars are put in group 1 and the trimmed body in group 2.") (declare-function org-toggle-archive-tag "org-archive" (&optional find-done)) (declare-function org-update-radio-target-regexp "ol" ()) -(defvar ffap-url-regexp) (defvar org-element-paragraph-separate) (defvar org-indent-indentation-per-level) (defvar org-radio-target-regexp) @@ -4539,7 +4538,7 @@ directory." (when (and (org-string-nw-p value) (not buffer-read-only)) ;FIXME: bug in Gnus? (let* ((uri (org-strip-quotes value)) - (uri-is-url (org-file-url-p uri)) + (uri-is-url (org-url-p uri)) (uri (if uri-is-url uri (expand-file-name uri)))) @@ -4669,11 +4668,6 @@ This is the cache of file URLs read using `org-file-contents'.") "Reset the cache of files downloaded by `org-file-contents'." (clrhash org--file-cache)) -(defun org-file-url-p (file) - "Non-nil if FILE is a URL." - (require 'ffap) - (string-match-p ffap-url-regexp file)) - (defun org-file-contents (file &optional noerror nocache) "Return the contents of FILE, as a string. @@ -4688,7 +4682,7 @@ from file or URL, and return nil. If NOCACHE is non-nil, do a fresh fetch of FILE even if cached version is available. This option applies only if FILE is a URL." - (let* ((is-url (org-file-url-p file)) + (let* ((is-url (org-url-p file)) (cache (and is-url (not nocache) (gethash file org--file-cache)))) @@ -17555,7 +17549,7 @@ Otherwise, return a user error." (let ((file (and (string-match "\\`\"\\(.*?\\)\"\\|\\S-+" value) (or (match-string 1 value) (match-string 0 value))))) - (when (org-file-url-p file) + (when (org-url-p file) (user-error "Files located with a URL cannot be edited")) (org-link-open-from-string (format "[[%s]]" (expand-file-name file))))))