Commit c2dc03e6 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Fix "void-variable elib-newtext" error message when viewing images.

Bug introduced in a4b10328.

* elib-string.el (string-replace-match): Track the renamed variables
  elib-string and elib-newtext.
  (elib-string-expand-newtext): Fixed the documentation now that the
    variables are renamed.
parent f060c5b4
2014-08-08 Per Cederqvist <ceder@lysator.liu.se>
Fix "void-variable elib-newtext" error message when viewing
images. (Bug introduced in a4b103283.)
* elib-string.el (string-replace-match): Track the renamed
variables elib-string and elib-newtext.
(elib-string-expand-newtext): Fixed the documentation now that the
variables are renamed.
2014-08-05 Christer Ekholm <che@chrekh.se> 2014-08-05 Christer Ekholm <che@chrekh.se>
* compatibility.el: Fixed misspelling of set-face-strikethru-p. * compatibility.el: Fixed misspelling of set-face-strikethru-p.
......
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
;; which work on strings instead of a buffer. The FIXEDCASE parameter ;; which work on strings instead of a buffer. The FIXEDCASE parameter
;; of replace-match is not implemented. ;; of replace-match is not implemented.
(defun string-replace-match (regexp string newtext &optional literal global) (defun string-replace-match (regexp elib-string elib-newtext &optional literal global)
"Replace first match of REGEXP in STRING with NEWTEXT. "Replace first match of REGEXP in ELIB-STRING with ELIB-NEWTEXT.
If no match is found, nil is returned instead of the new string. If no match is found, nil is returned instead of the new string.
Optional arg LITERAL non-nil means to take NEWTEXT literally. If LITERAL is Optional arg LITERAL non-nil means to take ELIB-NEWTEXT literally. If LITERAL is
nil, character `\\' is the start of one of the following sequences: nil, character `\\' is the start of one of the following sequences:
\\\\ will be replaced by a single \\. \\\\ will be replaced by a single \\.
\\& will be replaced by the text which matched the regexp. \\& will be replaced by the text which matched the regexp.
...@@ -80,34 +80,34 @@ Optional arg GLOBAL means to replace all matches instead of only the first." ...@@ -80,34 +80,34 @@ Optional arg GLOBAL means to replace all matches instead of only the first."
(start 0) (start 0)
matchbeginning matchbeginning
matchend) matchend)
(while (string-match regexp string start) (while (string-match regexp elib-string start)
(setq matchbeginning (match-beginning 0) (setq matchbeginning (match-beginning 0)
matchend (match-end 0) matchend (match-end 0)
result (concat result result (concat result
(substring string start matchbeginning) (substring elib-string start matchbeginning)
(if literal (if literal
newtext elib-newtext
(elib-string-expand-newtext))) (elib-string-expand-newtext)))
start matchend)) start matchend))
(if matchbeginning ; matched at least once (if matchbeginning ; matched at least once
(concat result (substring string start)) (concat result (substring elib-string start))
nil)) nil))
;; not GLOBAL ;; not GLOBAL
(if (not (string-match regexp string 0)) (if (not (string-match regexp elib-string 0))
nil nil
(concat (substring string 0 (match-beginning 0)) (concat (substring elib-string 0 (match-beginning 0))
(if literal newtext (elib-string-expand-newtext)) (if literal elib-newtext (elib-string-expand-newtext))
(substring string (match-end 0))))) (substring elib-string (match-end 0)))))
(store-match-data data)))) (store-match-data data))))
(defun elib-string-expand-newtext () (defun elib-string-expand-newtext ()
;; Expand \& and \1..\9 (referring to STRING) in NEWTEXT. ;; Expand \& and \1..\9 (referring to ELIB-STRING) in ELIB-NEWTEXT.
;; Uses match data and fluid vars `newtext', `string'. ;; Uses match data and fluid vars `elib-newtext', `elib-string'.
;; Note that in Emacs 18 match data are clipped to current buffer ;; Note that in Emacs 18 match data are clipped to current buffer
;; size...so the buffer should better not be smaller than STRING. ;; size...so the buffer should better not be smaller than ELIB-STRING.
(let ((pos 0) (let ((pos 0)
(len (length elib-newtext)) (len (length elib-newtext))
(expanded-newtext "")) (expanded-newtext ""))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment