0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 19:07:52 +00:00

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'.
This commit is contained in:
Nicolas Goaziou 2017-07-27 13:39:52 +02:00
parent ed6849d18d
commit f776e65373
3 changed files with 15 additions and 24 deletions

View file

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

View file

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

View file

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