(when (string-match ":" line)
(setq line (substring line 0 (match-beginning 0)))
(setq line (replace-regexp-in-string "[[(<{].*$" "" line))
- (setq line (replace-regexp-in-string "," "" line))
+ (setq line (string-replace "," "" line))
(dolist (file (split-string line))
(when (setq file (authors-canonical-file-name file log-file pos (car authors)))
(dolist (author authors)
'((("\\.\\([Hh]\\|hh\\|hpp\\|hxx\\|h\\+\\+\\)\\'" . "C / C++ header")
(replace-regexp-in-string
"[^A-Z0-9]" "_"
- (replace-regexp-in-string
- "\\+" "P"
+ (string-replace
+ "+" "P"
(upcase (file-name-nondirectory buffer-file-name))))
"#ifndef " str \n
"#define " str "\n\n"
(when match
(kill-line 1)
(setq line (concat line (substring curline 0 match))))
- (setq line (replace-regexp-in-string "SPC" " SPC "
- (replace-regexp-in-string " " "" line)))
+ (setq line (string-replace "SPC" " SPC "
+ (string-replace " " "" line)))
(insert line "\t\t\t")
(if (> (current-column) 24)
(delete-char -1))
(when match
(kill-line 1)
(setq line (concat line (substring curline 0 match))))
- (setq line (replace-regexp-in-string " " "" line))
+ (setq line (string-replace " " "" line))
(insert cmdbeg " " line "\t\t\t")
(if (> (current-column) 24)
(delete-char -1))
(when match
(kill-line 1)
(setq line (concat line (substring curline 0 match))))
- (setq line (replace-regexp-in-string " " "" line))
+ (setq line (string-replace " " "" line))
(insert line "\t\t\t")
(if (> (current-column) 24)
(delete-char -1))
If EXPR is nil, return nil."
(if expr
(let ((cexpr (math-compose-expr expr 0)))
- (replace-regexp-in-string
+ (string-replace
" / " "/"
(if (stringp cexpr)
cexpr
(defun cal-html-comment (string)
"Return STRING as html comment."
(format "<!-- ====== %s ====== -->\n"
- (replace-regexp-in-string "--" "++" string)))
+ (string-replace "--" "++" string)))
(defun cal-html-href (link string)
"Return a hyperlink to url LINK with text STRING."
COMMENT may contain newlines, which are prefixed by \"% \" in the output."
(insert (format "%% %s\n"
(if comment
- (replace-regexp-in-string "\n" "\n% " comment)
+ (string-replace "\n" "\n% " comment)
""))))
(defun cal-tex-banner (comment)
(defun icalendar--convert-string-for-export (string)
"Escape comma and other critical characters in STRING."
- (replace-regexp-in-string "," "\\\\," string))
+ (string-replace "," "\\," string))
(defun icalendar--convert-string-for-import (string)
"Remove escape chars for comma, semicolon etc. from STRING."
- (replace-regexp-in-string
- "\\\\n" "\n " (replace-regexp-in-string
- "\\\\\"" "\"" (replace-regexp-in-string
- "\\\\;" ";" (replace-regexp-in-string
- "\\\\," "," string)))))
+ (string-replace
+ "\\n" "\n " (string-replace
+ "\\\"" "\"" (string-replace
+ "\\;" ";" (string-replace
+ "\\," "," string)))))
;; ======================================================================
;; Export -- convert emacs-diary to iCalendar
(defun iso8601--concat-regexps (regexps)
(mapconcat (lambda (regexp)
(concat "\\(?:"
- (replace-regexp-in-string "(" "(?:" regexp)
+ (string-replace "(" "(?:" regexp)
"\\)"))
regexps "\\|"))
"\\(Z\\|\\([+-]\\)\\([0-9][0-9]\\):?\\([0-9][0-9]\\)?\\)")
(defconst iso8601--full-time-match
- (concat "\\(" (replace-regexp-in-string "(" "(?:" iso8601--time-match) "\\)"
+ (concat "\\(" (string-replace "(" "(?:" iso8601--time-match) "\\)"
"\\(" iso8601--zone-match "\\)?"))
(defconst iso8601--combined-match
(concat "\\(" iso8601--date-match "\\)"
"\\(?:T\\("
- (replace-regexp-in-string "(" "(?:" iso8601--time-match)
+ (string-replace "(" "(?:" iso8601--time-match)
"\\)"
"\\(" iso8601--zone-match "\\)?\\)?"))
(format " %s%s" name
(if (= num 1) "" "s"))))
t t string))))))
- (replace-regexp-in-string "%%" "%" string))
+ (string-replace "%%" "%" string))
(defvar seconds-to-string
(list (list 1 "ms" 0.001)
(let ((bufname (buffer-name)))
(string-match "\"\\([^\"]+\\)\"" bufname)
(let* ((filename-str (substring bufname (match-beginning 1) (match-end 1)))
- (filename-base (replace-regexp-in-string ", " "-" filename-str))
+ (filename-base (string-replace ", " "-" filename-str))
(top-priorities (string-match "top priorities" bufname))
(diary-items (string-match "diary items" bufname))
(regexp-items (string-match "regexp items" bufname)))
;; doubling `!'s in the original name...
(setq file (subst-char-in-string
?/ ?!
- (replace-regexp-in-string "!" "!!" file)))
+ (string-replace "!" "!!" file)))
file))
(defun cedet-file-name-to-directory-name (referencefile &optional testmode)
;; Replace the ! with /
(setq file (subst-char-in-string ?! ?/ file))
;; Occurrences of // meant there was once a single !.
- (setq file (replace-regexp-in-string "//" "!" file))
+ (setq file (string-replace "//" "!" file))
;; Handle Windows special cases
(when (or (memq system-type '(windows-nt ms-dos)) testmode)
This function could be in the list `comint-output-filter-functions'."
(when (let ((case-fold-search t))
(string-match comint-password-prompt-regexp
- (replace-regexp-in-string "\r" "" string)))
+ (string-replace "\r" "" string)))
(let ((comint--prompt-recursion-depth (1+ comint--prompt-recursion-depth)))
(if (> comint--prompt-recursion-depth 10)
(message "Password prompt recursion too deep")
(default
(and (stringp modestr)
(string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
- (replace-regexp-in-string
+ (string-replace
"-" ""
(format "u=%s,g=%s,o=%s"
(match-string 1 modestr)
(interactive)
(require 'man)
(let* ((file (dired-get-filename))
- (manual-program (replace-regexp-in-string "\\*" "%s"
+ (manual-program (string-replace "*" "%s"
(dired-guess-shell-command
"Man command: " (list file)))))
(Man-getpage-in-background file)))
;; because newlines in dirnames are uncommon, and people may
;; have gotten used to seeing unescaped "\" in the headers.
;; Note: adjust dired-build-subdir-alist if you change this.
- (setq dir (replace-regexp-in-string "\\\\" "\\\\" dir nil t)
- dir (replace-regexp-in-string "\n" "\\n" dir nil t)))
+ (setq dir (string-replace "\\" "\\\\" dir)
+ dir (string-replace "\n" "\\n" dir)))
;; If we used --dired and it worked, the lines are already indented.
;; Otherwise, indent them.
(unless (save-excursion
FULL-NAME specifies the actual file name the listing must have,
as returned by `dired-get-filename'. LIMIT is the search limit."
(let (str)
- (setq str (replace-regexp-in-string "\^m" "\\^m" file nil t))
- (setq str (replace-regexp-in-string "\\\\" "\\\\" str nil t))
+ (setq str (string-replace "\^m" "\\^m" file))
+ (setq str (string-replace "\\" "\\\\" str))
(and (dired-switches-escape-p dired-actual-switches)
(string-match-p "[ \t\n]" str)
;; FIXME: to fix this for embedded control characters etc, we
;; should escape everything that `ls -b' does.
- (setq str (replace-regexp-in-string " " "\\ " str nil t)
- str (replace-regexp-in-string "\t" "\\t" str nil t)
- str (replace-regexp-in-string "\n" "\\n" str nil t)))
+ (setq str (string-replace " " "\\ " str)
+ str (string-replace "\t" "\\t" str)
+ str (string-replace "\n" "\\n" str)))
(let ((found nil)
;; filenames are preceded by SPC, this makes the search faster
;; (e.g. for the filename "-").
do (aset str j (aref byte 0))
(aset str (1+ j) (aref byte 1))
finally return str))
- (human-readable (replace-regexp-in-string
+ (human-readable (string-replace
"-" "_" orig-name))
(human-readable (replace-regexp-in-string
(rx (not (any "0-9a-z_"))) "" human-readable)))
(let ((re (with-output-to-string
(print (reb-target-binding reb-regexp)))))
(setq re (substring re 1 (1- (length re))))
- (setq re (replace-regexp-in-string "\n" "\\n" re nil t))
+ (setq re (string-replace "\n" "\\n" re))
(kill-new re)
(message "Copied regexp `%s' to kill-ring" re)))
(define-inline erc-dcc-unquote-filename (filename)
(inline-quote
- (replace-regexp-in-string "\\\\\\\\" "\\"
- (replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t)))
+ (string-replace "\\\\" "\\"
+ (string-replace "\\\"" "\"" ,filename))))
(defun erc-dcc-handle-ctcp-send (proc query nick login host to)
"This is called if a CTCP DCC SEND subcommand is sent to the client.
If S is non-nil, it will be used as the quit reason."
(or s
(if (fboundp 'yow)
- (replace-regexp-in-string "\n" "" (yow))
+ (string-replace "\n" "" (yow))
(erc-quit/part-reason-default))))
(make-obsolete 'erc-quit-reason-zippy "it will be removed." "24.4")
If S is non-nil, it will be used as the quit reason."
(or s
(if (fboundp 'yow)
- (replace-regexp-in-string "\n" "" (yow))
+ (string-replace "\n" "" (yow))
(erc-quit/part-reason-default))))
(make-obsolete 'erc-part-reason-zippy "it will be removed." "24.4")
(fill-region (point-min) (point-max))
(buffer-string))))
(setq header-line-format
- (replace-regexp-in-string
+ (string-replace
"%"
"%%"
(if face
nick user host channel
(if (not (string= reason ""))
(format ": %s"
- (replace-regexp-in-string "%" "%%" reason))
+ (string-replace "%" "%%" reason))
"")))))
(expand-file-name
(subst-char-in-string
?/ ?!
- (replace-regexp-in-string "!" "!!" file))
+ (string-replace "!" "!!" file))
backup-directory))
(expand-file-name (file-name-nondirectory file)
(file-name-as-directory abs-backup-directory))))))
(file-name-directory result)
(subst-char-in-string
?/ ?!
- (replace-regexp-in-string
+ (string-replace
"!" "!!" filename))))
(t result))))
(setq result
(default
(and (stringp modestr)
(string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
- (replace-regexp-in-string
+ (string-replace
"-" ""
(format "u=%s,g=%s,o=%s"
(match-string 1 modestr)
:type `(choice
,@ (mapcar (lambda (style)
(let ((name
- (replace-regexp-in-string "-" " " (car style))))
+ (string-replace "-" " " (car style))))
`(const :tag
,(concat (capitalize (substring name 0 1))
(substring name 1))
")" (gnus-url-unhex-string (match-string 2 url)))))
((string-match "([^)\"]+)[^\"]+" url)
(setq url
- (replace-regexp-in-string
+ (string-replace
"\"" "" (replace-regexp-in-string "[\n\t ]+" " " url)))
(gnus-info-find-node url))
(t (error "Can't parse %s" url))))
require-match initial-input
(or hist 'gnus-group-history)
def)))
- (replace-regexp-in-string "\n" "" group)))
+ (string-replace "\n" "" group)))
;;;###autoload
(defun gnus-fetch-group (group &optional articles)
;; ugly, but cannot get
;;replace-regexp-in-string work with "\\" as
;;REP, plus we should also handle "\\;"
- (replace-regexp-in-string
- "\\\\," ","
- (replace-regexp-in-string
- "\\\\n" "\n" (substring-no-properties value))))))
+ (string-replace
+ "\\," ","
+ (string-replace
+ "\\n" "\n" (substring-no-properties value))))))
(accumulate-args
(mapping)
(cl-destructuring-bind (slot . ical-property) mapping
"\\)"))
;; Now create the new SPLIT
(let ((split-regexp-with-list-ids
- (replace-regexp-in-string "@" "[@.]" split-regexp t t))
+ (string-replace "@" "[@.]" split-regexp))
(exclude
;; Generate RESTRICTs for SPLIT-EXCLUDEs.
(if (listp split-exclude)
If VALUE is a relative time, interpret it as relative to
REL-DATE, or (current-time) if REL-DATE is nil."
;; Time parsing doesn't seem to work with slashes.
- (let ((value (replace-regexp-in-string "/" "-" value))
+ (let ((value (string-replace "/" "-" value))
(now (append '(0 0 0)
(seq-subseq (decode-time (or rel-date
(current-time)))
Mairix negation requires a \"~\" preceding string search terms,
and \"-\" before marks."
(let ((next (gnus-search-transform-expression engine (cadr expr))))
- (replace-regexp-in-string
+ (string-replace
":"
(if (eql (caadr expr) 'mark)
":-"
group
(if (file-directory-p
(setq group
- (replace-regexp-in-string
- "\\." "/"
- group nil t)))
+ (string-replace
+ "." "/"
+ group)))
group))))))
(unless group
(signal 'gnus-search-config-error
(goto-char (point-max))
;; Make sure that each dribble entry is a single line, so that
;; the "remove" code above works.
- (insert (replace-regexp-in-string "\n" "\\\\n" string) "\n")
+ (insert (string-replace "\n" "\\n" string) "\n")
(bury-buffer gnus-dribble-buffer)
(with-current-buffer gnus-group-buffer
(gnus-group-set-mode-line)))))
(interactive "sMessage-ID: " gnus-summary-mode)
(when (and (stringp message-id)
(not (zerop (length message-id))))
- (setq message-id (replace-regexp-in-string " " "" message-id))
+ (setq message-id (string-replace " " "" message-id))
;; Construct the correct Message-ID if necessary.
;; Suggested by tale@pawl.rpi.edu.
(unless (string-match "^<" message-id)
(defun gnus-mode-string-quote (string)
"Quote all \"%\"'s in STRING."
- (replace-regexp-in-string "%" "%%" string))
+ (string-replace "%" "%%" string))
(defsubst gnus-make-hashtable (&optional size)
"Make a hash table of SIZE, testing on `equal'."
(let ((value (message-field-value header)))
(dolist (string (mail-header-parse-addresses value 'raw))
(setq string
- (replace-regexp-in-string
+ (string-replace
"\n" ""
(replace-regexp-in-string "^ +\\| +$" "" string)))
(ecomplete-add-item 'mail (car (mail-header-parse-address string))
(defun message-parse-mailto-url (url)
"Parse a mailto: url."
- (setq url (replace-regexp-in-string "\n" " " url))
+ (setq url (string-replace "\n" " " url))
(when (string-match "mailto:/*\\(.*\\)" url)
(setq url (substring url (match-beginning 1) nil)))
(setq url (if (string-match "^\\?" url)
(dolist (arg args)
(unless (equal (car arg) "body")
(message-position-on-field (capitalize (car arg)))
- (insert (replace-regexp-in-string
+ (insert (string-replace
"\r\n" "\n"
- (mapconcat #'identity (reverse (cdr arg)) ", ") nil t))))
+ (mapconcat #'identity (reverse (cdr arg)) ", ")))))
(when (assoc "body" args)
(message-goto-body)
(dolist (body (cdr (assoc "body" args)))
(if (eq 'OpenPGP protocol)
(epg-sign-string context (buffer-string) mode)
(epg-sign-string context
- (replace-regexp-in-string
+ (string-replace
"\n" "\r\n" (buffer-string))
t))
mml-secure-secret-key-id-list nil)
nil t)))))
(mm-sec-error 'gnus-info "Corrupted")
(throw 'error handle))
- (setq part (replace-regexp-in-string "\n" "\r\n" part)
+ (setq part (string-replace "\n" "\r\n" part)
context (epg-make-context 'CMS))
(condition-case error
;; (setq plain
nil t))))
(mm-sec-error 'gnus-info "Corrupted")
(throw 'error handle))
- (setq part (replace-regexp-in-string "\n" "\r\n" part)
+ (setq part (string-replace "\n" "\r\n" part)
signature (mm-get-part signature)
context (epg-make-context))
(condition-case error
(funcall func (cdr entry)))))))
(defun nnmaildir--system-name ()
- (replace-regexp-in-string
+ (string-replace
":" "\\072"
- (replace-regexp-in-string
+ (string-replace
"/" "\\057"
- (replace-regexp-in-string "\\\\" "\\134" (system-name) nil 'literal)
- nil 'literal)
- nil 'literal))
+ (string-replace "\\" "\\134" (system-name)))))
(defun nnmaildir-request-type (_group &optional _article)
'mail)
(setq pgname (nnmaildir--pgname nnmaildir--cur-server gname)
ro (nnmaildir--param pgname 'read-only))
- (insert (replace-regexp-in-string
+ (insert (string-replace
" " "\\ "
- (nnmaildir--grp-name group) nil t)
+ (nnmaildir--grp-name group))
" ")
(princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
nntp-server-buffer)
(princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
nntp-server-buffer)
(insert " "
- (replace-regexp-in-string " " "\\ " gname nil t)
+ (string-replace " " "\\ " gname)
"\n")))))
'group)
(insert " ")
(princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
nntp-server-buffer)
- (insert " " (replace-regexp-in-string " " "\\ " gname nil t) "\n")
+ (insert " " (string-replace " " "\\ " gname) "\n")
t))))
(defun nnmaildir-request-create-group (gname &optional server _args)
(insert "\t" (nnmaildir--nov-get-beg nov) "\t"
(nnmaildir--art-msgid article) "\t"
(nnmaildir--nov-get-mid nov) "\tXref: nnmaildir "
- (replace-regexp-in-string " " "\\ " gname nil t) ":")
+ (string-replace " " "\\ " gname) ":")
(princ num nntp-server-buffer)
(insert "\t" (nnmaildir--nov-get-end nov) "\n"))))
(catch 'return
(nnrss-node-just-text node)
node))
(cleaned-text (if text
- (replace-regexp-in-string
+ (string-replace
"\r\n" "\n"
(replace-regexp-in-string
"^[\000-\037\177]+\\|^ +\\| +$" ""
rpt-host
(concat
"/"
- (replace-regexp-in-string
+ (string-replace
"/" ":"
(replace-regexp-in-string
"^.*article.gmane.org/" ""
(defcustom spam-report-user-mail-address
(and (stringp user-mail-address)
- (replace-regexp-in-string "@" "<at>" user-mail-address))
+ (string-replace "@" "<at>" user-mail-address))
"Mail address of this user used for spam reports to Gmane.
This is initialized based on `user-mail-address'."
:type '(choice string
(ibuffer-buffer-name-face buffer mark))))
(if (not (seq-position string ?\n))
string
- (replace-regexp-in-string
+ (string-replace
"\n" (propertize "^J" 'font-lock-face 'escape-glyph) string))))
(define-ibuffer-column size
(thumb (cdr (assq ?t spec))))
(rename-file nq8 thumb t)))
(message "command %S %s" (process-command process)
- (replace-regexp-in-string "\n" "" status)))))
+ (string-replace "\n" "" status)))))
process))
(defun image-dired-pngcrush-thumb (spec)
(unless (and (eq (process-status process) 'exit)
(zerop (process-exit-status process)))
(message "command %S %s" (process-command process)
- (replace-regexp-in-string "\n" "" status)))
+ (string-replace "\n" "" status)))
(when (memq (process-status process) '(exit signal))
(let ((temp (cdr (assq ?q spec))))
(delete-file temp)))))
(unless (and (eq (process-status process) 'exit)
(zerop (process-exit-status process)))
(message "command %S %s" (process-command process)
- (replace-regexp-in-string "\n" "" status)))))
+ (string-replace "\n" "" status)))))
process))
(defun image-dired-create-thumb-1 (original-file thumbnail-file)
(zerop (process-exit-status process))))
(message "Thumb could not be created for %s: %s"
(abbreviate-file-name original-file)
- (replace-regexp-in-string "\n" "" status))
+ (string-replace "\n" "" status))
(set-file-modes thumbnail-file #o600)
(clear-image-cache thumbnail-file)
;; PNG thumbnail has been created since we are
(concat
" ("
(if (stringp Info-current-file)
- (replace-regexp-in-string
+ (string-replace
"%" "%%"
(file-name-sans-extension
(file-name-nondirectory Info-current-file)))
(format "*%S*" Info-current-file))
") "
(if Info-current-node
- (propertize (replace-regexp-in-string
+ (propertize (string-replace
"%" "%%" Info-current-node)
'face 'mode-line-buffer-id
'help-echo
(let ((str (eval (get-language-info language-name 'sample-text))))
(if (stringp str)
(insert "Sample text:\n "
- (replace-regexp-in-string "\n" "\n " str)
+ (string-replace "\n" "\n " str)
"\n\n")))
(error nil))
(let ((input-method (get-language-info language-name 'input-method))
(let (mod)
(when (and (string-match "\\\\\"" string)
(not (string-match "\\`\"\\|[^\\]\"" string)))
- (setq string (replace-regexp-in-string "\\\\\"" "\"" string)
+ (setq string (string-replace "\\\"" "\"" string)
mod t))
(when (and (string-match "\\\\(" string)
(string-match "\\\\)" string)
calling this function."
(let ((case-fold-search t)
prequery query headers-alist)
- (setq mailto-url (replace-regexp-in-string "\n" " " mailto-url))
+ (setq mailto-url (string-replace "\n" " " mailto-url))
(if (string-match rfc2368-mailto-regexp mailto-url)
(progn
(setq prequery
(file-name-nondirectory
(if (memq system-type '(windows-nt cygwin ms-dos))
;; cannot have colons in file name
- (replace-regexp-in-string ":" "-" file)
+ (string-replace ":" "-" file)
file)))
;; Use the directory of this rmail file
;; because it's a nuisance to use the homedir
;; Hide commas so it will work ok if parsed as a comma-separated list
;; of regexps.
(setq subject
- (replace-regexp-in-string "," "\054" subject t t))
+ (string-replace "," "\054" subject))
(concat "\\`" subject "\\'")))
(defun rmail-next-same-subject (n)
(or (mail-fetch-field "Subject")
rmail-default-body-file)))
(setq default-file
- (replace-regexp-in-string ":" "-" default-file))
+ (string-replace ":" "-" default-file))
(setq default-file
- (replace-regexp-in-string " " "-" default-file))
+ (string-replace " " "-" default-file))
(list (setq rmail-default-body-file
(read-file-name
"Output message body to file: "
;; Undo masking of separators inside digestified messages
(goto-char (point-min))
(while (search-forward
- (replace-regexp-in-string "\n-" "\n " separator) nil t)
+ (string-replace "\n-" "\n " separator) nil t)
(replace-match separator))
;; Return the list of marker pairs
(nreverse result))))))
;; added by troff, and remove it.
(or (not (eq (string-to-char (substring 1st-part -1)) ?-))
(string-match-p "-" (substring 1st-part 0 -1))
- (setq word (replace-regexp-in-string "-" "" word))))
+ (setq word (string-replace "-" "" word))))
;; Make sure the section number gets included by the code below.
(goto-char (match-end 1)))
(when (string-match "[-._‐]+$" word)
`(keymap
,(format "%s - %s" indicator
(capitalize
- (replace-regexp-in-string
+ (string-replace
"-" " " (format "%S" minor-mode))))
(turn-off menu-item "Turn off minor mode" ,mm-fun)
(help menu-item "Help for minor mode"
(with-current-buffer "*MPC-debug*"
(goto-char (point-max))
(insert-before-markers ;So it scrolls.
- (replace-regexp-in-string "\n" "\n "
- (apply #'format-message format args))
+ (string-replace "\n" "\n "
+ (apply #'format-message format args))
"\n"))))
(defun mpc--proc-filter (proc string)
(insert "\n"))
(goto-char (prog1
(point)
- (insert (replace-regexp-in-string "\r\n" "\n" body))
+ (insert (string-replace "\r\n" "\n" body))
(unless (bolp)
(insert "\n"))))))))
(propertize "...: " 'face
'variable-pitch))))
(propertize "..." 'face 'variable-pitch)))))))
- (replace-regexp-in-string
+ (string-replace
"%" "%%"
(format-spec
eww-header-line-format
(interactive)
(let ((filename (read-string "Filename: "
(concat feed ":_"
- (replace-regexp-in-string
+ (string-replace
" " "_" (newsticker--title item))
".html"))))
(with-temp-buffer
(defun rcirc-sentinel (process sentinel)
"Called when PROCESS receives SENTINEL."
- (let ((sentinel (replace-regexp-in-string "\n" "" sentinel)))
+ (let ((sentinel (string-replace "\n" "" sentinel)))
(rcirc-debug process (format "SENTINEL: %S %S\n" process sentinel))
(with-rcirc-process-buffer process
(dolist (buffer (cons nil (mapcar 'cdr rcirc-buffer-alist)))
(if second
(if second-fraction
(let* ((second-fraction-significand
- (replace-regexp-in-string "\\." "" second-fraction))
+ (string-replace "." "" second-fraction))
(hertz
(expt 10 (length second-fraction-significand)))
(ticks (+ (* hertz (string-to-number second))
"Regular expression to match a single-quoted literal.")
(defconst rng-c-literal-2-re
- (replace-regexp-in-string "'" "\"" rng-c-literal-1-re)
+ (string-replace "'" "\"" rng-c-literal-1-re)
"Regular expression to match a double-quoted literal.")
(defconst rng-c-ncname-re "\\w+")
"[^<'&\r\n\t]*"
(xmltok-g complex1 "[&\r\n\t][^<']*") opt
"'"))
- (lit2 (cons (replace-regexp-in-string "'" "\"" (car lit1))
+ (lit2 (cons (string-replace "'" "\"" (car lit1))
'(complex2)))
(literal (xmltok-g literal lit1 or lit2))
(name (xmltok+ open (xmltok-g xmlns "xmlns") or ncname close
;; eliminate all ".", "/", "\" from beginning. Always matches.
(string-match "^[./\\]*\\(.*\\)$" dirnam)
;; "/" -> "."
- (setq group (replace-regexp-in-string
+ (setq group (string-replace
"/" "." (match-string 1 dirnam)))
;; Windows "\\" -> "."
- (setq group (replace-regexp-in-string "\\\\" "." group))
+ (setq group (string-replace "\\" "." group))
(push (vector (gnus-group-full-name group server)
(string-to-number artno)
(when (string-match prefix dirnam)
(setq dirnam (replace-match "" t t dirnam)))
(push (vector (gnus-group-full-name
- (replace-regexp-in-string "/" "." dirnam) server)
+ (string-replace "/" "." dirnam) server)
(string-to-number artno)
(string-to-number score))
artlist))
group
(if (file-directory-p
(setq group
- (replace-regexp-in-string
- "\\." "/"
- group nil t)))
+ (string-replace
+ "." "/"
+ group)))
group))))))
(unless group
(error "Cannot locate directory for group"))
(dun-mprincl "Incorrect.")))
(let (varname epoint afterq i value)
- (setq varname (replace-regexp-in-string " " "" (substring line 0 esign)))
+ (setq varname (string-replace " " "" (substring line 0 esign)))
(if (or (= (length varname) 0) (< (- (length line) esign) 2))
(progn
(concat "\\\\" (cdr trans))
line)))
(switch-to-buffer ps-buf-name)
- (insert (replace-regexp-in-string "\n" "" line))
+ (insert (string-replace "\n" "" line))
(message "write write write...")
(setq ps-ypos (+ ps-ypos handwrite-linespace))
(end-of-line)
(defun proced-format-args (args)
"Format attribute ARGS.
Replace newline characters by \"^J\" (two characters)."
- (replace-regexp-in-string "\n" "^J" args))
+ (string-replace "\n" "^J" args))
(defun proced-format (process-alist format)
"Display PROCESS-ALIST using FORMAT."
(defun profiler-report-header-line-format (fmt &rest args)
(let* ((header (apply #'profiler-format fmt args))
- (escaped (replace-regexp-in-string "%" "%%" header)))
+ (escaped (string-replace "%" "%%" header)))
(concat
(propertize " "
'display '(space :align-to 0)
The string is enclosed in double quotes.
All embedded quotes, newlines, and backslashes are preceded with a backslash."
(setq string (replace-regexp-in-string "\\([\"\\]\\)" "\\\\\\&" string))
- (setq string (replace-regexp-in-string "\n" "\\n" string t t))
+ (setq string (string-replace "\n" "\\n" string))
(concat "\"" string "\""))
(defun gdb-input (command handler-function &optional trigger-name)
"Regex used to highlight makepp rule action lines in font lock mode.")
(defconst makefile-bsdmake-rule-action-regex
- (replace-regexp-in-string "-@" "-+@" makefile-rule-action-regex)
+ (string-replace "-@" "-+@" makefile-rule-action-regex)
"Regex used to highlight BSD rule action lines in font lock mode.")
;; Note that the first and second subexpression is used by font lock. Note
,@(if keywords
;; Fontify conditionals and includes.
`((,(concat "^\\(?: [ \t]*\\)?"
- (replace-regexp-in-string
+ (string-replace
" " "[ \t]+"
(if (eq (car keywords) t)
- (replace-regexp-in-string "-" "[_-]"
- (regexp-opt (cdr keywords) t))
+ (string-replace "-" "[_-]" (regexp-opt (cdr keywords) t))
(regexp-opt keywords t)))
"\\>[ \t]*\\([^: \t\n#]*\\)")
(1 font-lock-keyword-face) (2 font-lock-variable-name-face))))
;(goto-char beg)
(if (search-forward-regexp "^[ \t]*\\(%+\\|\\*+\\|/\\*+\\)[ \t]*"
end t)
- (replace-regexp-in-string "/" " " (buffer-substring beg (point)))
+ (string-replace "/" " " (buffer-substring beg (point)))
(beginning-of-line)
(when (search-forward-regexp "^[ \t]+" end t)
(buffer-substring beg (point)))))))))
(buffer-substring-no-properties (1+ min) (1- max))))
(setq content
(if (equal string-quote "'")
- (replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)'" "\\1\\\\'" content))
- (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)\"" "\\1\\\\\"" content))))
+ (string-replace "\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)'" "\\1\\\\'" content))
+ (string-replace "\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)\"" "\\1\\\\\"" content))))
(let ((orig-point (point)))
(delete-region min max)
(insert
(defun sql-remove-tabs-filter (str)
"Replace tab characters with spaces."
- (replace-regexp-in-string "\t" " " str nil t))
+ (string-replace "\t" " " str))
(defun sql-toggle-pop-to-buffer-after-send-region (&optional value)
"Toggle `sql-pop-to-buffer-after-send-region'.
"If non-nil, display messages related to the use of redirection.")
(defun sql-str-literal (s)
- (concat "'" (replace-regexp-in-string "[']" "''" s) "'"))
+ (concat "'" (string-replace "[']" "''" s) "'"))
(defun sql-redirect (sqlbuf command &optional outbuf save-prior)
"Execute the SQL command and send output to OUTBUF.
(defvar which-func-table (make-hash-table :test 'eq :weakness 'key))
(defconst which-func-current
- '(:eval (replace-regexp-in-string
+ '(:eval (string-replace
"%" "%%"
(or (gethash (selected-window) which-func-table)
which-func-unknown))))
(when query-replace-from-to-separator
;; Check if the first non-whitespace char is displayable
(if (char-displayable-p
- (string-to-char (replace-regexp-in-string
+ (string-to-char (string-replace
" " "" query-replace-from-to-separator)))
query-replace-from-to-separator
" -> ")))
;; Add non-numeric prefix to all non-first lines
;; of multi-line matches.
(concat
- (replace-regexp-in-string
+ (string-replace
"\n"
(if prefix-face
(propertize
with the `noescape' argument set.
`match-data' is preserved across the call."
- (save-match-data
- (replace-regexp-in-string "\\\\" "\\\\"
- (if (stringp replacement)
- replacement
- (prin1-to-string replacement t))
- t t)))
+ (string-replace "\\" "\\\\"
+ (if (stringp replacement)
+ replacement
+ (prin1-to-string replacement t))))
(defun replace-loop-through-replacements (data count)
;; DATA is a vector containing the following values:
(error "Unknown selection type: %S" type)))))
;; Most programs are unable to handle NUL bytes in strings.
- (setq str (replace-regexp-in-string "\0" "\\0" str t t))
+ (setq str (string-replace "\0" "\\0" str))
(setq next-selection-coding-system nil)
(cons type str))))
(push "'" result)
(setq item (cadr item)))
(setq item (ses-prin1 item))
- (setq item (replace-regexp-in-string "\t" "\\\\t" item))
+ (setq item (string-replace "\t" "\\t" item))
(push item result)
(cond
((< col maxcol)
"''"
;; Quote everything except POSIX filename characters.
;; This should be safe enough even for really weird shells.
- (replace-regexp-in-string
+ (string-replace
"\n" "'\n'"
(replace-regexp-in-string "[^-0-9a-zA-Z_./\n]" "\\\\\\&" argument))))
))
(not cursor-in-echo-area)) ;Don't overwrite a prompt.
(cond
((stringp help)
- (setq help (replace-regexp-in-string "\n" ", " help))
+ (setq help (string-replace "\n" ", " help))
(unless (or msdos-previous-message
(string-equal help (current-message))
(and (stringp msdos-last-help-message)
;;; Fix interface to (X-specific) mouse.el
(defun w32--set-selection (type value)
(if (eq type 'CLIPBOARD)
- (w32-set-clipboard-data (replace-regexp-in-string "\0" "\\0" value t t))
+ (w32-set-clipboard-data (string-replace "\0" "\\0" value))
(put 'x-selections (or type 'PRIMARY) value)))
(defun w32--get-selection (&optional type data-type)
'terminal-init-screen))
(bytes (encode-coding-string data 'utf-8-unix))
(base-64 (if screen
- (replace-regexp-in-string
+ (string-replace
"\n" "\e\\\eP"
- (base64-encode-string bytes)
- :fixedcase :literal)
+ (base64-encode-string bytes))
(base64-encode-string bytes :no-line-break)))
(length (length base-64)))
(if (> length xterm-max-cut-length)
(progn
(beginning-of-line)
(skip-chars-backward
- (concat "^" (replace-regexp-in-string
- "\\\\" "\\\\" picture-tab-chars nil t))
+ (concat "^" (string-replace
+ "\\" "\\\\" picture-tab-chars))
(point-min))
(not (bobp))))
(move-to-column target))
(defun thumbs-call-setroot-command (img)
"Call the setroot program for IMG."
(run-hooks 'thumbs-before-setroot-hook)
- (shell-command (replace-regexp-in-string
- "\\*"
+ (shell-command (string-replace
+ "*"
(shell-quote-argument (expand-file-name img))
- thumbs-setroot-command nil t))
+ thumbs-setroot-command))
(run-hooks 'thumbs-after-setroot-hook))
(defun thumbs-set-image-at-point-to-root-window ()
(not cursor-in-echo-area)) ;Don't overwrite a prompt.
(cond
((stringp help)
- (setq help (replace-regexp-in-string "\n" ", " help))
+ (setq help (string-replace "\n" ", " help))
(unless (or tooltip-previous-message
(equal-including-properties help (current-message))
(and (stringp tooltip-help-message)
((equal (seq-take seq len) transient--redisplay-key)
(let ((pre (key-description (vconcat (seq-take seq len))))
(suf (key-description (vconcat (seq-drop seq len)))))
- (setq pre (replace-regexp-in-string "RET" "C-m" pre t))
- (setq pre (replace-regexp-in-string "TAB" "C-i" pre t))
- (setq suf (replace-regexp-in-string "RET" "C-m" suf t))
- (setq suf (replace-regexp-in-string "TAB" "C-i" suf t))
+ (setq pre (string-replace "RET" "C-m" pre))
+ (setq pre (string-replace "TAB" "C-i" pre))
+ (setq suf (string-replace "RET" "C-m" suf))
+ (setq suf (string-replace "TAB" "C-i" suf))
;; We use e.g. "-k" instead of the more correct "- k",
;; because the former is prettier. If we did that in
;; the definition, then we want to drop the space that
;; is reinserted above. False-positives are possible
;; for silly bindings like "-C-c C-c".
(unless (string-match-p " " key)
- (setq pre (replace-regexp-in-string " " "" pre))
- (setq suf (replace-regexp-in-string " " "" suf)))
+ (setq pre (string-replace " " "" pre))
+ (setq suf (string-replace " " "" suf)))
(concat (propertize pre 'face 'default)
(and (string-prefix-p (concat pre " ") key) " ")
(transient--colorize-key suf cmd)
(goto-char (point-max)))
(insert (mapconcat
(lambda (string)
- (replace-regexp-in-string "\r\n" "\n" string))
+ (string-replace "\r\n" "\n" string))
(cdar args) "\n")))
(url-mail-goto-field (caar args))
;; (setq func (intern-soft (concat "mail-" (caar args))))
(not (looking-at (format ".+ .+ <%s>"
(regexp-quote mail))))
(looking-at ".+ \\(.+ <.+>\\) *\\((tiny change)\\)?"))
- (let ((author (replace-regexp-in-string " " " "
- (match-string 1))))
+ (let ((author (string-replace " " " "
+ (match-string 1))))
(unless (and log-edit-author
(string-match (regexp-quote author)
(car log-edit-author)))
;; Erase the status text that matched.
(delete-region (match-beginning 0) (match-end 0))
(setq status
- (intern (replace-regexp-in-string " " "" statusword)))))
+ (intern (string-replace " " "" statusword)))))
(when status
(goto-char (point-min))
(skip-chars-forward " \n\t") ;Throw away spaces.
(push "\\[" parts))
(t
(let ((x (substring glob i j)))
- (setf x (replace-regexp-in-string
- "\\\\" "\\\\" x t t))
+ (setf x (string-replace
+ "\\" "\\\\" x))
(setf i (1+ j))
(cond ((eq (aref x 0) ?!)
(setf (aref x 0) ?^))
(let ((state (cdr (assq (aref (match-string 1) 0) state-map)))
(propstat (cdr (assq (aref (match-string 2) 0) state-map)))
(filename (if (memq system-type '(windows-nt ms-dos))
- (replace-regexp-in-string "\\\\" "/" (match-string 4))
+ (string-replace "\\" "/" (match-string 4))
(match-string 4))))
(and (memq propstat '(conflict edited))
(not (eq state 'conflict)) ; conflict always wins
"Partition VALUE into elements delimited by unescaped semicolons."
(let (res)
(setq value (string-trim-left value))
- (dolist (x (split-string (replace-regexp-in-string "\\\\;" "\0" value) ";"))
- (push (replace-regexp-in-string "\0" ";" x) res))
+ (dolist (x (split-string (string-replace "\\;" "\0" value) ";"))
+ (push (string-replace "\0" ";" x) res))
(when (null (string-match-p "[^[:blank:]]" (car res))) (pop res))
(nreverse res)))
"")
char
(if (string= fixture expected-string) "stay" "become")
- (replace-regexp-in-string "\n" "\\\\n" expected-string)
+ (string-replace "\n" "\\n" expected-string)
expected-point)))
`(ert-deftest ,(intern (format "electric-pair-%s-at-point-%s-in-%s%s"
name
first line\r
next line\r\n"))
(should (equal (term-test-screen-from-input 40 12 str)
- (replace-regexp-in-string "\r" "" str)))))
+ (string-replace "\r" "" str)))))
(ert-deftest term-carriage-return ()
(skip-unless (not (memq system-type '(windows-nt ms-dos))))
(defun formatz-mod-del-colons (string)
"Returns STRING with any colons removed."
- (replace-regexp-in-string ":" "" string))
+ (string-replace ":" "" string))
(defun formatz-mod-add-00 (string)
"Returns STRING with \"00\" appended."
(let* ((test-dir (make-temp-file "test-dir-" t))
(test-file (concat (file-name-as-directory test-dir) "foo.c"))
(replace "bar")
- (new-file (replace-regexp-in-string "foo" replace test-file))
+ (new-file (string-replace "foo" replace test-file))
(wdired-use-interactive-rename t))
(write-region "" nil test-file nil 'silent)
(advice-add 'dired-query ; Don't ask confirmation to overwrite a file.
(let* ((test-dir (make-temp-file "test-dir-" t))
(test-file (concat (file-name-as-directory test-dir) "foo.c"))
(replace "bar")
- (new-file (replace-regexp-in-string "foo" replace test-file)))
+ (new-file (string-replace "foo" replace test-file)))
(write-region "" nil test-file nil 'silent)
(let ((buf (find-file-noselect test-dir)))
(unwind-protect
(let* ((input
"{ \"abc\" : [9, false] , \"def\" : null }")
(output
- (replace-regexp-in-string " " "" input)))
+ (string-replace " " "" input)))
(should (equal (json-parse-string input
:object-type 'plist
:null-object :json-null