branch: externals/hyperbole
commit 7c955443b40aba08e60fa30c5432b654bdcecd13
Author: Mats Lidell <[email protected]>
Commit: GitHub <[email protected]>

    Use replace regexp in string (#210)
---
 ChangeLog          |  7 +++++
 hargs.el           |  4 +--
 hbut.el            | 12 ++++-----
 hib-kbd.el         | 44 ++++++++++++++++----------------
 hmail.el           |  8 +++---
 hmouse-info.el     |  8 +++---
 hmouse-tag.el      | 14 +++++-----
 hpath.el           | 18 ++++++-------
 hypb.el            |  4 ++-
 hyrolo-logic.el    | 36 +++++++++++++-------------
 kotl/kcell.el      |  6 ++---
 kotl/kexport.el    | 18 ++++++-------
 kotl/kimport.el    |  8 +++---
 kotl/klink.el      |  6 ++---
 kotl/kotl-mode.el  | 28 ++++++++++----------
 kotl/kview.el      |  8 +++---
 kotl/kvspec.el     | 10 ++++----
 test/hypb-tests.el | 75 ++----------------------------------------------------
 18 files changed, 126 insertions(+), 188 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 535f35c2ac..202940fcb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-07-15  Mats Lidell  <[email protected]>
+
+* test/hypb-tests.el: Remove test cases for hypb:replace-match-string.
+
+* hypb.el (hypb:replace-match-string): Mark as obsolete. Replace all
+    calls, in numerous places, to use replace-regexp-in-string.
+
 2022-07-13  Stefan Monnier  <[email protected]>
 
 * hrmail.el (rmail-cease-edit, rmail-forward, rmail-get-new-mail)
diff --git a/hargs.el b/hargs.el
index ba35ebd507..305254c02f 100644
--- a/hargs.el
+++ b/hargs.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    31-Oct-91 at 23:17:35
-;; Last-Mod:     20-Feb-22 at 22:15:24 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 22:07:35 by Mats Lidell
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -150,7 +150,7 @@ With optional EXCLUDE-REGEXP, any matched string is ignored 
if it matches this r
             (>= end opoint)
             (let ((string (hargs:buffer-substring start end)))
               (unless (and (stringp exclude-regexp) (string-match 
exclude-regexp string) )
-                (setq string (hypb:replace-match-string "[\n\r\f]\\s-*" string 
" " t))
+                (setq string (replace-regexp-in-string "[\n\r\f]\\s-*" " " 
string nil t))
                 (unless hyperb:microsoft-os-p
                   (setq string (hpath:mswindows-to-posix string)))
                 (if list-positions-flag
diff --git a/hbut.el b/hbut.el
index 849870d2db..10fe130fc0 100644
--- a/hbut.el
+++ b/hbut.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    18-Sep-91 at 02:57:09
-;; Last-Mod:     15-May-22 at 23:07:36 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 22:07:35 by Mats Lidell
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -1032,7 +1032,7 @@ Ignore email-related buffers."
   (when (string-match "\n" label)
     (mapc (lambda (prefix)
            (when (string-match "\n" label)
-             (setq label (hypb:replace-match-string prefix label " " t))))
+             (setq label (replace-regexp-in-string prefix " " label nil t))))
          hbut:fill-prefix-regexps))
   label)
 
@@ -1260,10 +1260,10 @@ whitespace sequences with `_'."
   (when label
     (setq label (hbut:fill-prefix-remove label)
          ;; Remove leading and trailing space.
-         label (hypb:replace-match-string "\\`[ \t\n\r]+\\|[ \t\n\r]+\\'"
-                                          label "" t)
-         label (hypb:replace-match-string "_" label "__" t))
-    (hypb:replace-match-string "[ \t\n\r]+" label "_" t)))
+         label (replace-regexp-in-string "\\`[ \t\n\r]+\\|[ \t\n\r]+\\'"
+                                          "" label nil t)
+         label (replace-regexp-in-string "_" "__" label nil t))
+    (replace-regexp-in-string "[ \t\n\r]+" "_" label nil t)))
 
 (defun    hbut:map (but-func &optional start-delim end-delim
                             regexp-match include-delims)
diff --git a/hib-kbd.el b/hib-kbd.el
index 20e66447ff..1fdb10c57e 100644
--- a/hib-kbd.el
+++ b/hib-kbd.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    22-Nov-91 at 01:37:57
-;; Last-Mod:     12-Jun-22 at 15:57:09 by Mats Lidell
+;; Last-Mod:     15-Jul-22 at 23:21:33 by Mats Lidell
 ;;
-;; Copyright (C) 1991-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -288,34 +288,34 @@ keyboad input queue, as if they had been typed by the 
user."
                   norm-key-series (kbd-key:mark-spaces-to-keep norm-key-series 
"\\[" "\\]")
                   norm-key-series (kbd-key:mark-spaces-to-keep norm-key-series 
"<" ">")
                   norm-key-series (kbd-key:mark-spaces-to-keep norm-key-series 
"\"" "\"")
-                  norm-key-series (hypb:replace-match-string
-                                   "<DEL>\\|<DELETE>\\|@key{DEL}\\|\\<DEL\\>" 
norm-key-series " DEL " t)
-                  norm-key-series (hypb:replace-match-string
-                                   "<BS>\\|<BACKSPACE>\\|@key{BS}\\|\\<BS\\>" 
norm-key-series " BS " t)
-                  norm-key-series (hypb:replace-match-string
+                  norm-key-series (replace-regexp-in-string
+                                   "<DEL>\\|<DELETE>\\|@key{DEL}\\|\\<DEL\\>" 
" DEL " norm-key-series nil t)
+                  norm-key-series (replace-regexp-in-string
+                                   "<BS>\\|<BACKSPACE>\\|@key{BS}\\|\\<BS\\>" 
" BS " norm-key-series nil t)
+                  norm-key-series (replace-regexp-in-string
                                    
"<RET>\\|<RTN>\\|<RETURN>\\|@key{RET}\\|@key{RTN}\\|\\<RETURN\\>\\|\\<RET\\>\\|\\<RTN\\>"
-                                   norm-key-series " RET " t)
-                  norm-key-series (hypb:replace-match-string
-                                   "<TAB>\\|@key{TAB}\\|\\<TAB\\>" 
norm-key-series " TAB " t)
+                                   " RET " norm-key-series nil t)
+                  norm-key-series (replace-regexp-in-string
+                                   "<TAB>\\|@key{TAB}\\|\\<TAB\\>" " TAB " 
norm-key-series nil t)
                   ;; Includes conversion of spaces-to-keep markup to
                   ;; SPC; otherwise, later calls to `kbd' will remove
                   ;; these spaces.
-                  norm-key-series (hypb:replace-match-string
-                                   "\\\\ 
\\|\0\0\0\\|<SPC>\\|@key{SPC}\\|\\<SPC\\>" norm-key-series " SPC " t)
-                  norm-key-series (hypb:replace-match-string
-                                   
"<ESC>\\|<ESCAPE>\\|@key{ESC}\\|\\<ESC\\(APE\\)?\\>" norm-key-series " M-" t)
+                  norm-key-series (replace-regexp-in-string
+                                   "\\\\ 
\\|\0\0\0\\|<SPC>\\|@key{SPC}\\|\\<SPC\\>" " SPC " norm-key-series nil t)
+                  norm-key-series (replace-regexp-in-string
+                                   
"<ESC>\\|<ESCAPE>\\|@key{ESC}\\|\\<ESC\\(APE\\)?\\>" " M-" norm-key-series nil 
t)
                   ;; ESC ESC
-                  norm-key-series (hypb:replace-match-string
-                                   "M-[ \t\n\r\f]*M-" norm-key-series " ESC 
M-" t)
+                  norm-key-series (replace-regexp-in-string
+                                   "M-[ \t\n\r\f]*M-" " ESC M-" 
norm-key-series nil t)
                   ;; Separate with a space any keys with a modifier
-                  norm-key-series (hypb:replace-match-string 
kbd-key:modified-key-regexp
-                                                             norm-key-series " 
\\1\\3 ")
+                  norm-key-series (replace-regexp-in-string 
kbd-key:modified-key-regexp
+                                                             " \\1\\3 " 
norm-key-series)
                   ;; Normalize regular whitespace to single spaces
-                  norm-key-series (hypb:replace-match-string "[ \t\n\r\f]+" 
norm-key-series " " t)
+                  norm-key-series (replace-regexp-in-string "[ \t\n\r\f]+" " " 
norm-key-series nil t)
 
                   ;; Unqote special {} chars.
-                  norm-key-series (hypb:replace-match-string "\\\\\\([{}]\\)"
-                                                             norm-key-series 
"\\1")
+                  norm-key-series (replace-regexp-in-string "\\\\\\([{}]\\)"
+                                                             "\\1" 
norm-key-series)
                   norm-key-series (hpath:trim norm-key-series))
             ;; (while (string-match "\\`\\(C-u\\|M-\\)\\(-?[0-9]+\\)" 
norm-key-series)
             ;;   (setq arg (string-to-number (match-string 2 norm-key-series))
@@ -493,7 +493,7 @@ Also, initialize `kbd-key:mini-menu-key' to the key 
sequence that invokes the Hy
            end (match-end 0)
            substring (match-string 0 string)
            string (concat (substring string 0 start)
-                          (hypb:replace-match-string "[ \t\n\r\f]" substring 
"\0\0\0" t)
+                          (replace-regexp-in-string "[ \t\n\r\f]" "\0\0\0" 
substring nil t)
                           (if (< end (length string))
                               (substring string end)
                             ""))
diff --git a/hmail.el b/hmail.el
index 4c059c5227..153897f722 100644
--- a/hmail.el
+++ b/hmail.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     9-Oct-91 at 18:38:05
-;; Last-Mod:      6-Mar-22 at 22:29:00 by Mats Lidell
+;; Last-Mod:     15-Jul-22 at 23:22:06 by Mats Lidell
 ;;
-;; Copyright (C) 1991-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the HY-COPY (Hyperbole) or BR-COPY (OO-Browser) file for license
 ;; information.
 ;;
@@ -147,8 +147,8 @@ Optional SUBJECT and HELP message may also be given."
                                      0 (string-match "-" reader-name))))
           hmail-func)
       (mapcar (lambda (func-suffix)
-               (setq hmail-func (hypb:replace-match-string
-                                 "Summ-" func-suffix "" t))
+               (setq hmail-func (replace-regexp-in-string
+                                 "Summ-" "" func-suffix nil t))
                (defalias (intern (concat class-prefix hmail-func))
                  (intern (concat reader-prefix "-" func-suffix))))
              func-suffix-list))))
diff --git a/hmouse-info.el b/hmouse-info.el
index 0c06a683a0..ac7fd989a2 100644
--- a/hmouse-info.el
+++ b/hmouse-info.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    04-Apr-89
-;; Last-Mod:     17-Apr-22 at 11:16:29 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:22:20 by Mats Lidell
 ;;
-;; Copyright (C) 1989-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1989-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -352,8 +352,8 @@ This works regardless of the current buffer."
               (<= (match-beginning 0) opoint)
               (> (match-end 0) opoint))
          ;; Remove newline and extra spaces from `note-name'
-         (hypb:replace-match-string "[ \t\n\r]+" (match-string-no-properties 2)
-                                    " " t)))))
+         (replace-regexp-in-string "[ \t\n\r]+" " "
+                                    (match-string-no-properties 2) nil t)))))
 
 (defun Info-read-index-item-name-1 (string predicate code)
   "Internal function used by `Info-read-index-item-name' to generate 
completions.
diff --git a/hmouse-tag.el b/hmouse-tag.el
index e34011f82b..a6f88a081c 100644
--- a/hmouse-tag.el
+++ b/hmouse-tag.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    24-Aug-91
-;; Last-Mod:     17-Apr-22 at 23:15:45 by Mats Lidell
+;; Last-Mod:     15-Jul-22 at 22:07:35 by Mats Lidell
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -1284,8 +1284,8 @@ Look for packages in `smart-java-package-path'."
              (let ((library-path (smart-java-library-path referent)))
                (if library-path
                    (hpath:find (expand-file-name
-                                (hypb:replace-match-string
-                                 "\\." referent (file-name-as-directory "") t)
+                                (replace-regexp-in-string
+                                 "\\." (file-name-as-directory "") referent 
nil t)
                                 library-path))
                  ;; Show the current directory, which should contain this 
package.
                  (hpath:find default-directory)))
@@ -1294,10 +1294,10 @@ Look for packages in `smart-java-package-path'."
            ;; package.
            (if (string-match "\\.\\*" referent)
                (setq subfile (substring referent 0 (match-beginning 0))
-                     subfile (hypb:replace-match-string
-                              "\\." subfile (file-name-as-directory "") t))
-             (setq subpath (hypb:replace-match-string
-                            "\\." referent (file-name-as-directory "") t)
+                     subfile (replace-regexp-in-string
+                              "\\." (file-name-as-directory "") subfile nil t))
+             (setq subpath (replace-regexp-in-string
+                            "\\." (file-name-as-directory "") referent nil t)
                    subfile (concat subpath ".java")))
            ;;
            ;; Try to find the path containing referent.
diff --git a/hpath.el b/hpath.el
index 92e971f63e..3cdf8629f0 100644
--- a/hpath.el
+++ b/hpath.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     1-Nov-91 at 00:44:23
-;; Last-Mod:     22-May-22 at 13:34:43 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:23:25 by Mats Lidell
 ;;
-;; Copyright (C) 1991-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -1631,8 +1631,8 @@ form is what is returned for PATH."
                                      ;; Quote any % except for one %s at the 
end of the
                                      ;; path part of rtn-path (immediately 
preceding a #
                                      ;; or , character or the end of string).
-                                     (setq rtn-path (hypb:replace-match-string 
"%" rtn-path "%%" nil t)
-                                           rtn-path (hypb:replace-match-string 
"%%s\\([#,]\\|\\'\\)" rtn-path "%s\\1" nil t))
+                                     (setq rtn-path (replace-regexp-in-string 
"%" "%%" rtn-path t nil)
+                                           rtn-path (replace-regexp-in-string 
"%%s\\([#,]\\|\\'\\)" "%s\\1" rtn-path t nil))
                                      ;; Return path if non-nil return value.
                                      (if (stringp suffix) ;; suffix could = t, 
which we ignore
                                          (if (string-match (concat 
(regexp-quote suffix) "%s") rtn-path)
@@ -2375,9 +2375,9 @@ that returns a replacement string."
             rtn-str
             (substring str prev-start match)
             (cond ((functionp new)
-                   (hypb:replace-match-string
-                    regexp (substring str match start)
-                    (funcall new str) literal fixedcase))
+                   (replace-regexp-in-string
+                    regexp (funcall new str)
+                    (substring str match start) fixedcase literal))
                   (literal new)
                   (t (mapconcat
                       (lambda (c)
@@ -2407,10 +2407,10 @@ that returns a replacement string."
 Replacement is done iff VAR-DIR-VAL is an absolute path.
 If PATH is modified, return PATH, otherwise return nil."
   (when (and (stringp var-dir-val) (file-name-absolute-p var-dir-val))
-    (let ((new-path (hypb:replace-match-string
+    (let ((new-path (replace-regexp-in-string
                     (regexp-quote (file-name-as-directory
                                    (or var-dir-val default-directory)))
-                    path (concat "$\{" (symbol-name var-symbol) "\}/")
+                    (concat "$\{" (symbol-name var-symbol) "\}/") path
                     t t)))
       (if (equal new-path path) nil new-path))))
 
diff --git a/hypb.el b/hypb.el
index fcf41d5c41..724e25a014 100644
--- a/hypb.el
+++ b/hypb.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     6-Oct-91 at 03:42:38
-;; Last-Mod:     19-Jun-22 at 14:50:52 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:08:28 by Mats Lidell
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -544,6 +544,8 @@ WINDOW pixelwise."
        ((symbolp object)
         (get object 'hyperbole))))
 
+(make-obsolete 'hypb:replace-match-string 'replace-regexp-in-string "9.0")
+
 (defun hypb:replace-match-string (regexp str new &optional literal fixedcase)
   "Replace all matches for REGEXP in STR with NEW string and return the result.
 If NEW is nil, return STR unchanged.
diff --git a/hyrolo-logic.el b/hyrolo-logic.el
index da7823ac35..964e0dfb77 100644
--- a/hyrolo-logic.el
+++ b/hyrolo-logic.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    13-Jun-89 at 22:57:33
-;; Last-Mod:     10-Apr-22 at 09:53:39 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:23:52 by Mats Lidell
 ;;
-;; Copyright (C) 1989-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1989-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -101,28 +101,28 @@ single argument."
        ;; Search string does not contain embedded logic
        ;; operators; do a string search instead.
        (setq total-matches (hyrolo-fgrep expr))
-      (setq expr (hypb:replace-match-string "\(or " expr "\(| " t))
-      (setq expr (hypb:replace-match-string "\(xor " expr "\(@ " t))
-      (setq expr (hypb:replace-match-string "\(not " expr "\(! " t))
-      (setq expr (hypb:replace-match-string "\(and " expr "\(& " t))
-      (setq expr (hypb:replace-match-string
-                 "\"\\([^\"]*\\)\"" expr "{\\1}" nil))
-      (setq expr (hypb:replace-match-string
-                 "\(\\([^@|!&()][^()\"]*\\)\)" expr "{\\1}" nil))
+      (setq expr (replace-regexp-in-string "\(or " "\(| " expr nil t))
+      (setq expr (replace-regexp-in-string "\(xor " "\(@ " expr nil t))
+      (setq expr (replace-regexp-in-string "\(not " "\(! " expr nil t))
+      (setq expr (replace-regexp-in-string "\(and " "\(& " expr nil t))
+      (setq expr (replace-regexp-in-string
+                 "\"\\([^\"]*\\)\"" "{\\1}" expr nil nil))
+      (setq expr (replace-regexp-in-string
+                 "\(\\([^@|!&()][^()\"]*\\)\)" "{\\1}" expr nil nil))
       (let ((saved-expr expr))
        (while
            (not (equal
                  saved-expr
-                 (setq expr (hypb:replace-match-string
+                 (setq expr (replace-regexp-in-string
                              "\\(\\s-\\)\\([^{}()\" 
\t\n\r]+\\)\\([^{}()]*[()]\\)"
-                             expr "\\1\"\\2\"\\3" nil))))
+                             "\\1\"\\2\"\\3" expr nil nil))))
          (setq saved-expr expr)))
-      (setq expr (hypb:replace-match-string
-                 "{\\([^{}]+\\)}" expr "\"\\1\"" nil))
-      (setq expr (hypb:replace-match-string "\(| " expr "\(hyrolo-or start end 
 " t))
-      (setq expr (hypb:replace-match-string "\(@ " expr "\(hyrolo-xor start 
end " t))
-      (setq expr (hypb:replace-match-string "\(! " expr "\(hyrolo-not start 
end " t))
-      (setq expr (hypb:replace-match-string "\(& " expr "\(hyrolo-and start 
end " t))
+      (setq expr (replace-regexp-in-string
+                 "{\\([^{}]+\\)}" "\"\\1\"" expr nil nil))
+      (setq expr (replace-regexp-in-string "\(| " "\(hyrolo-or start end  " 
expr nil t))
+      (setq expr (replace-regexp-in-string "\(@ " "\(hyrolo-xor start end " 
expr nil t))
+      (setq expr (replace-regexp-in-string "\(! " "\(hyrolo-not start end " 
expr nil t))
+      (setq expr (replace-regexp-in-string "\(& " "\(hyrolo-and start end " 
expr nil t))
       (setq expr (format "(hyrolo-logic (quote %s) nil %s %s %s)"
                         expr count-only include-sub-entries 
no-sub-entries-out))
       (setq total-matches (eval (read expr))))
diff --git a/kotl/kcell.el b/kotl/kcell.el
index 3272014198..adb5697e22 100644
--- a/kotl/kcell.el
+++ b/kotl/kcell.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     1-May-93
-;; Last-Mod:     22-May-22 at 10:22:02 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:24:10 by Mats Lidell
 ;;
-;; Copyright (C) 1993-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -109,7 +109,7 @@ Augment capabilities not yet implemented and ignored for 
now:
          ((stringp cell-ref)
           (let (kviewspec
                 idstamp-string)
-            (setq cell-ref (hypb:replace-match-string "\\s-+" cell-ref "" t))
+            (setq cell-ref (replace-regexp-in-string "\\s-+" "" cell-ref nil 
t))
             (if (string-equal cell-ref "0")
                 "0"
               ;; Ignore Augment :viewspec.
diff --git a/kotl/kexport.el b/kotl/kexport.el
index 79ba0632a3..ef4e356afa 100644
--- a/kotl/kexport.el
+++ b/kotl/kexport.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    26-Feb-98
-;; Last-Mod:     12-Feb-22 at 10:42:20 by Mats Lidell
+;; Last-Mod:     15-Jul-22 at 23:24:27 by Mats Lidell
 ;;
-;; Copyright (C) 1998-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1998-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -455,10 +455,10 @@ hard newlines are not used.  Also converts Urls and 
Klinks into Html hyperlinks.
        ;;      </menu>
        ;;     </nav>\n")
        (let* ((separator
-               (hypb:replace-match-string
-                ">" (hypb:replace-match-string
-                     "<" (kview:label-separator kview) "&lt;")
-                "&gt;"))
+               (replace-regexp-in-string
+                ">" "&gt;"
+                (replace-regexp-in-string
+                     "<" "&lt;" (kview:label-separator kview))))
               i is-parent is-last-sibling no-sibling-stack level label 
contents)
          (kview:map-tree
           (lambda (_kview)
@@ -533,7 +533,7 @@ hard newlines are not used.  Also converts Urls and Klinks 
into Html hyperlinks.
 
 (defun kexport:html-file-klink (string)
   "Convert STRING containing a klink with a file reference to Html format.
-Works exclusively within a call to `hypb:replace-match-string'."
+Works exclusively within a call to `replace-regexp-in-string'."
   (let ((filename (substring string (match-beginning 1)
                             (match-end 1))))
     (if (equal filename (file-name-nondirectory
@@ -549,13 +549,13 @@ Works exclusively within a call to 
`hypb:replace-match-string'."
   "Perform replacements on STRING specified by 
`kexport:html-replacement-alist'."
   (mapc
    (lambda (elt)
-     (setq string (hypb:replace-match-string (car elt) string (cdr elt))))
+     (setq string (replace-regexp-in-string (car elt) (cdr elt) string)))
    kexport:html-replacement-alist)
   string)
 
 (defun kexport:html-url (string)
   "Convert STRING containing a Url to Html format.
-Works exclusively within a call to `hypb:replace-match-string'."
+Works exclusively within a call to `replace-regexp-in-string'."
   (let* ((url (substring string (match-beginning hpath:url-grpn)
                         (match-end hpath:url-grpn)))
         (last-str-char (length string))
diff --git a/kotl/kimport.el b/kotl/kimport.el
index 7cf0d171d8..4cb3924db5 100644
--- a/kotl/kimport.el
+++ b/kotl/kimport.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    15-Nov-93 at 11:57:05
-;; Last-Mod:     11-Apr-22 at 23:51:03 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:24:41 by Mats Lidell
 ;;
-;; Copyright (C) 1993-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -716,8 +716,8 @@ Remove the indent and return the remaining region as a 
string."
            (if (re-search-forward "[\n\r][ \t]+" end t)
                (concat "^" (make-string (current-column) ?\ ))))
       (if indent-regexp
-         (hypb:replace-match-string
-                         indent-regexp (buffer-substring start end) "" t)
+         (replace-regexp-in-string
+                         indent-regexp "" (buffer-substring start end) nil t)
        (buffer-substring start end)))))
 
 ;; Do this at the end so kotl-mode can utilize kimport definitions.
diff --git a/kotl/klink.el b/kotl/klink.el
index 91fb1a3251..f2df4729ed 100644
--- a/kotl/klink.el
+++ b/kotl/klink.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    15-Nov-93 at 12:15:16
-;; Last-Mod:     22-May-22 at 12:52:17 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:24:53 by Mats Lidell
 ;;
-;; Copyright (C) 1993-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -114,7 +114,7 @@ See documentation for `kcell:ref-to-id' for valid cell-ref 
formats."
   ;; double quotes and then parse it with pattern matching.
   (and (stringp reference) (> (length reference) 0)
        (eq (aref reference 0) ?\()
-       (setq reference (hypb:replace-match-string "\\\"" reference "" t)))
+       (setq reference (replace-regexp-in-string "\\\"" "" reference nil t)))
   (let ((default-dir default-directory)
        file-ref cell-ref)
     (setq reference (klink:parse reference)
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index ac3b57fa53..aee67c283f 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    6/30/93
-;; Last-Mod:     18-Jun-22 at 21:56:13 by Mats Lidell
+;; Last-Mod:     15-Jul-22 at 22:07:35 by Mats Lidell
 ;;
 ;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
@@ -374,10 +374,10 @@ With optional prefix arg DELETE-FLAG, delete region."
   (interactive "cCopy to register: \nr\nP")
   (let ((indent (kcell-view:indent)))
     (set-register register
-                 (hypb:replace-match-string
+                 (replace-regexp-in-string
                   (concat "^" (make-string indent ?\ ))
-                  (buffer-substring start end)
-                  "" t)))
+                  ""
+                  (buffer-substring start end) nil t)))
   (when delete-flag
     (delete-region start end)))
 
@@ -745,8 +745,8 @@ If a completion is active, this aborts the completion only."
       ;; Then save to kill ring.
       (setq subst-str (concat "\\([\n\r]\\)" (make-string indent ?\ ))
            kill-str
-           (hypb:replace-match-string
-            subst-str (buffer-substring start end) "\\1"))
+           (replace-regexp-in-string
+            subst-str "\\1" (buffer-substring start end)))
       (unless copy-p
        ;; If last char of region is a newline, then delete indent in
        ;; following line.
@@ -1339,8 +1339,8 @@ See also the command `yank-pop' (\\[yank-pop])."
         (indent-str (make-string indent ?\ )))
     ;; Convert all occurrences of newline to newline + cell indent.
     ;; Then insert into buffer.
-    (insert-for-yank (hypb:replace-match-string
-                     "[\n\r]" yank-text (lambda (match) (concat match 
indent-str)))))
+    (insert-for-yank (replace-regexp-in-string
+                     "[\n\r]" (lambda (match) (concat match indent-str)) 
yank-text)))
   (when (consp arg) (kotl-mode:exchange-point-and-mark))
   ;; If we do get all the way thru, make this-command indicate that.
   (when (eq this-command t) (setq this-command 'kotl-mode:yank))
@@ -1380,8 +1380,8 @@ doc string for `insert-for-yank-1', which see."
           (indent-str (make-string indent ?\ )))
       ;; Convert all occurrences of newline to newline + cell indent.
       ;; Then insert into buffer.
-      (insert-for-yank (hypb:replace-match-string
-                       "[\n\r]" yank-text (concat "\\0" indent-str))))
+      (insert-for-yank (replace-regexp-in-string
+                       "[\n\r]" (concat "\\0" indent-str) yank-text)))
     ;; Set the window start back where it was in the yank command,
     ;; if possible.
     (set-window-start (selected-window) yank-window-start t)
@@ -2377,9 +2377,9 @@ to one level and kotl-mode:refill-flag is treated as 
true."
       ;; Substitute cell-1 contents into cell-2 location.
       (delete-region (kcell-view:start) (kcell-view:end-contents))
       (insert
-       (hypb:replace-match-string
+       (replace-regexp-in-string
        "\\([\n\r]\\)"
-       contents-1 (concat "\\1" (make-string (kcell-view:indent) ?\ ))))
+       (concat "\\1" (make-string (kcell-view:indent) ?\ )) contents-1))
       (when kotl-mode:refill-flag
        (kotl-mode:fill-cell))
 
@@ -2389,9 +2389,9 @@ to one level and kotl-mode:refill-flag is treated as 
true."
       (delete-region (kcell-view:start) (kcell-view:end-contents))
       ;; Add indentation to all but first line.
       (insert
-       (hypb:replace-match-string
+       (replace-regexp-in-string
        "\\([\n\r]\\)"
-       contents-2 (concat "\\1" (make-string (kcell-view:indent) ?\ ))))
+       (concat "\\1" (make-string (kcell-view:indent) ?\ )) contents-2))
       (when kotl-mode:refill-flag
        (kotl-mode:fill-cell))
 
diff --git a/kotl/kview.el b/kotl/kview.el
index 9157361590..0cb3e0515c 100644
--- a/kotl/kview.el
+++ b/kotl/kview.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    6/30/93
-;; Last-Mod:     11-May-22 at 00:54:33 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:25:24 by Mats Lidell
 ;;
-;; Copyright (C) 1993-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1993-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -212,9 +212,9 @@ Any cell that is invisible is also collapsed as indicated 
by a call to
          (start (kcell-view:start))
          (end (kcell-view:end-contents)))
       ;; Remove indentation from all but first line.
-      (hypb:replace-match-string
+      (replace-regexp-in-string
        (concat "\\([\n\r]\\)" (make-string indent ?\ ))
-       (buffer-substring start end) "\\1"))))
+       "\\1" (buffer-substring start end)))))
 
 (defun kcell-view:create (kview cell contents level idstamp klabel &optional 
no-fill sibling-p)
   "Insert into KVIEW at point, CELL with CONTENTS at LEVEL (1 = first level) 
with IDSTAMP and KLABEL.
diff --git a/kotl/kvspec.el b/kotl/kvspec.el
index ad95e07ff6..a9ecba903d 100644
--- a/kotl/kvspec.el
+++ b/kotl/kvspec.el
@@ -3,9 +3,9 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    21-Oct-95 at 15:17:07
-;; Last-Mod:     11-May-22 at 00:51:57 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:25:45 by Mats Lidell
 ;;
-;; Copyright (C) 1995-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1995-2022  Free Software Foundation, Inc.
 ;; See the "../HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -131,7 +131,7 @@ display all levels of cells."
   (interactive)
   (setq kvspec:current
        (if (string-match "b" kvspec:current)
-           (hypb:replace-match-string "b" kvspec:current "" t)
+           (replace-regexp-in-string "b" "" kvspec:current nil t)
          (concat "b" kvspec:current)))
   (kvspec:blank-lines)
   (kvspec:update-modeline))
@@ -146,8 +146,8 @@ view specs."
   (cond ((stringp view-spec)
         ;; Use given view-spec after removing extraneous characters.
         (setq view-spec
-              (hypb:replace-match-string
-               "[^.*~0-9abcdefgilnrsv]+" view-spec "" t))
+              (replace-regexp-in-string
+               "[^.*~0-9abcdefgilnrsv]+" "" view-spec nil t))
         (unless (string-match "e" view-spec)
           ;; Force 'e' elide view spec if not there.
           (setq view-spec
diff --git a/test/hypb-tests.el b/test/hypb-tests.el
index 3cff5a3f9a..1c0de33404 100644
--- a/test/hypb-tests.el
+++ b/test/hypb-tests.el
@@ -3,9 +3,9 @@
 ;; Author:       Mats Lidell <[email protected]>
 ;;
 ;; Orig-Date:     5-Apr-21 at 18:53:10
-;; Last-Mod:      5-Feb-22 at 21:21:59 by Bob Weiner
+;; Last-Mod:     15-Jul-22 at 23:26:35 by Mats Lidell
 ;;
-;; Copyright (C) 2022  Free Software Foundation, Inc.
+;; Copyright (C) 2021-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -21,77 +21,6 @@
 (require 'ert)
 (require 'el-mock)
 
-;; Test for replace-regexp-in-string copied from emacs src
-(ert-deftest hypb:replace-match-string-test ()
-  (should (equal (hypb:replace-match-string "a+" "abaabbabaaba" "xy")
-                 "xybxybbxybxybxy"))
-  ;; FIXEDCASE
-  (let ((case-fold-search t))
-    (should (equal (hypb:replace-match-string "a+" "ABAABBABAABA" "xy")
-                   "XYBXYBBXYBXYBXY"))
-    (should (equal (hypb:replace-match-string "a+" "ABAABBABAABA" "xy" nil t)
-                   "xyBxyBBxyBxyBxy"))
-    (should (equal (hypb:replace-match-string
-                    "a[bc]*" "a A ab AB Ab aB abc ABC Abc AbC aBc" "xyz")
-                   "xyz XYZ xyz XYZ Xyz xyz xyz XYZ Xyz Xyz xyz"))
-    (should (equal (hypb:replace-match-string
-                    "a[bc]*" "a A ab AB Ab aB abc ABC Abc AbC aBc" "xyz" nil t)
-                   "xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz")))
-  (let ((case-fold-search nil))
-    (should (equal (hypb:replace-match-string "a+" "ABAABBABAABA" "xy")
-                   "ABAABBABAABA")))
-  ;; group substitution
-  (should (equal (hypb:replace-match-string
-                  "a\\(b*\\)" "babbcaabacbab" "<\\1,\\&>")
-                 "b<bb,abb>c<,a><b,ab><,a>cb<b,ab>"))
-  (should (equal (hypb:replace-match-string
-                  "x\\(?2:..\\)\\(?1:..\\)\\(..\\)\\(..\\)\\(..\\)"
-                  "yxabcdefghijkl" "<\\3,\\5,\\4,\\1,\\2>")
-                 "y<ef,ij,gh,cd,ab>kl"))
-  ;; LITERAL
-  (should (equal (hypb:replace-match-string
-                  "a\\(b*\\)" "babbcaabacbab" "<\\1,\\&>" t nil)
-                 "b<\\1,\\&>c<\\1,\\&><\\1,\\&><\\1,\\&>cb<\\1,\\&>"))
-  (should (equal (hypb:replace-match-string
-                  "a" "aba" "\\\\,\\?")
-                 "\\,\\?b\\,\\?"))
-  (should (equal (hypb:replace-match-string
-                  "a" "aba" "\\\\,\\?" t nil)
-                 "\\\\,\\?b\\\\,\\?"))
-  ;; SUBEXP
-  ; Available in subr-replace-regexp-in-string. Not supported here
-  ; (should (equal (hypb:replace-match-string
-  ;                 "\\(a\\)\\(b*\\)c" "xy" "babbcdacd" nil nil 2)
-  ;                "baxycdaxycd"))
-  ;; START
-  ; Available in subr-replace-regexp-in-string. Not supported here
-  ; (should (equal (hypb:replace-match-string
-  ;                 "ab" "x" "abcabdabeabf" nil nil nil 4)
-  ;                "bdxexf"))
-  ;; An empty pattern matches once before every character.
-  (should (equal (hypb:replace-match-string "" "abc" "x")
-                 "xaxbxc"))
-  (should (equal (hypb:replace-match-string "y*" "abc" "x")
-                 "xaxbxc"))
-  ;; replacement function
-  (should (equal (hypb:replace-match-string
-                  "a\\(b*\\)c"
-                  "babbcaacabc"
-                  (lambda (s)
-                    (format "<%s,%s,%s,%s,%s>"
-                            s
-                            (match-beginning 0) (match-end 0)
-                            (match-beginning 1) (match-end 1))))
-                 "b<abbc,0,4,1,3>a<ac,0,2,1,1><abc,0,3,1,2>")))
-
-(ert-deftest hypb:replace-match-string-after-27.1-test ()
-  ;; anchors (bug#15107, bug#44861)
-  (when (version< "27.1" emacs-version)
-    (should (equal (hypb:replace-match-string "a\\B" "a aaaa" "b")
-                   "a bbba"))
-    (should (equal (hypb:replace-match-string "\\`\\|x" "--xx--" "z")
-                   "z--zz--"))))
-
 (ert-deftest hypb:installation-type-test ()
   "Verify installation type alternatives."
   ;; straight.el package install -- hyperbole gnu-elpa-mirror master 56cd3d8 
2022-02-05

Reply via email to