compat: Add compatibility wrapper for string-clean-whitespace

* lisp/org-compat.el (org-string-clean-whitespace): New compatibility
function.
* lisp/ox.el (org-export-resolve-radio-link): Use
org-string-clean-whitespace.

This is a follow-up to the port of Emacs's 70341cab3.
This commit is contained in:
Kyle Meyer 2022-10-04 17:42:27 -04:00
parent 0e0fe76ae4
commit 98e168b489
2 changed files with 14 additions and 2 deletions

View File

@ -148,6 +148,18 @@ inserted before contatenating."
(and (file-directory-p dir)
(null (directory-files dir nil directory-files-no-dot-files-regexp t)))))
(if (fboundp 'string-clean-whitespace)
(defalias 'org-string-clean-whitespace #'string-clean-whitespace)
;; From Emacs subr-x.el.
(defun org-string-clean-whitespace (string)
"Clean up whitespace in STRING.
All sequences of whitespaces in STRING are collapsed into a
single space character, and leading/trailing whitespace is
removed."
(let ((blank "[[:blank:]\r\n]+"))
(string-trim (replace-regexp-in-string blank " " string t t)
blank blank))))
;;; Emacs < 27.1 compatibility

View File

@ -4454,11 +4454,11 @@ INFO is a plist used as a communication channel.
Return value can be a radio-target object or nil. Assume LINK
has type \"radio\"."
(let ((path (string-clean-whitespace (org-element-property :path link))))
(let ((path (org-string-clean-whitespace (org-element-property :path link))))
(org-element-map (plist-get info :parse-tree) 'radio-target
(lambda (radio)
(and (string-equal-ignore-case
(string-clean-whitespace (org-element-property :value radio))
(org-string-clean-whitespace (org-element-property :value radio))
path)
radio))
info 'first-match)))