Преглед изворни кода

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.
Kyle Meyer пре 2 година
родитељ
комит
98e168b489
2 измењених фајлова са 14 додато и 2 уклоњено
  1. 12 0
      lisp/org-compat.el
  2. 2 2
      lisp/ox.el

+ 12 - 0
lisp/org-compat.el

@@ -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
 

+ 2 - 2
lisp/ox.el

@@ -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)))