فهرست منبع

Move `org-split-string' to "org-macs.el"

* lisp/org.el (org-split-string): Move the function...
* lisp/org-macs.el (org-split-string): ... here.  Also clarify
  docstring with regards to `split-string'.
Nicolas Goaziou 7 سال پیش
والد
کامیت
f776e65373
3فایلهای تغییر یافته به همراه15 افزوده شده و 24 حذف شده
  1. 0 1
      lisp/ob-core.el
  2. 15 0
      lisp/org-macs.el
  3. 0 23
      lisp/org.el

+ 0 - 1
lisp/ob-core.el

@@ -82,7 +82,6 @@
 (declare-function org-reverse-string "org" (string))
 (declare-function org-set-outline-overlay-data "org" (data))
 (declare-function org-show-context "org" (&optional key))
-(declare-function org-split-string "org" (string &optional separators))
 (declare-function org-src-coderef-format "org-src" (element))
 (declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
 (declare-function org-table-align "org-table" ())

+ 15 - 0
lisp/org-macs.el

@@ -45,6 +45,21 @@ Otherwise, return nil."
        (string-match-p "[^ \r\t\n]" s)
        s))
 
+(defun org-split-string (string &optional separators)
+  "Splits STRING into substrings at SEPARATORS.
+
+SEPARATORS is a regular expression.  When nil, it defaults to
+\"[ \f\t\n\r\v]+\".
+
+Unlike to `split-string', matching SEPARATORS at the beginning
+and end of string are ignored."
+  (let ((separators (or separators "[ \f\t\n\r\v]+")))
+    (when (string-match (concat "\\`" separators) string)
+      (setq string (replace-match "" nil nil string)))
+    (when (string-match (concat separators "\\'") string)
+      (setq string (replace-match "" nil nil string)))
+    (split-string string separators)))
+
 (defun org-not-nil (v)
   "If V not nil, and also not the string \"nil\", then return V.
 Otherwise return nil."

+ 0 - 23
lisp/org.el

@@ -21998,29 +21998,6 @@ The return value is a list of lines, without newlines at the end."
       (setq lines (push line lines)))
     (nreverse lines)))
 
-(defun org-split-string (string &optional separators)
-  "Splits STRING into substrings at SEPARATORS.
-SEPARATORS is a regular expression.
-No empty strings are returned if there are matches at the beginning
-and end of string."
-  ;; FIXME: why not use (split-string STRING SEPARATORS t)?
-  (let ((start 0) notfirst list)
-    (while (and (string-match (or separators "[ \f\t\n\r\v]+") string
-			      (if (and notfirst
-				       (= start (match-beginning 0))
-				       (< start (length string)))
-				  (1+ start) start))
-		(< (match-beginning 0) (length string)))
-      (setq notfirst t)
-      (or (eq (match-beginning 0) 0)
-	  (and (eq (match-beginning 0) (match-end 0))
-	       (eq (match-beginning 0) start))
-	  (push (substring string start (match-beginning 0)) list))
-      (setq start (match-end 0)))
-    (or (eq start (length string))
-	(push (substring string start) list))
-    (nreverse list)))
-
 (defun org-quote-vert (s)
   "Replace \"|\" with \"\\vert\"."
   (while (string-match "|" s)