help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

does with-temp-buffer respect case-replace?


From: Xah
Subject: does with-temp-buffer respect case-replace?
Date: Wed, 29 Oct 2008 06:41:17 -0700 (PDT)
User-agent: G2/1.0

It seems that “with-temp-buffer” does not respect the var case-
replace?

here's a test code that replace some string in a region. It does this
by first grabing the region's text, then create temp buffer, insert
text, do replacement, grab the text back, then replace it in the
original buffer.

(defun tt (p1 p2)
  "Do a bunch of find/replace on current text selection."
  (interactive "r")

  (let (mystr)
    (setq mystr (buffer-substring p1 p2))
    (setq mystr
          (with-temp-buffer
            (setq case-fold-search nil)
            (setq case-replace t)
            (insert mystr)

            ;; Alt+t
            (goto-char (point-min))
            (while
                (search-forward-regexp "Alt\\+\\([[:graph:]]\\)" nil
t)
              (replace-match "<span class=\"kbd\"><span class=\"key
\">Alt</span>+<span class=\"key\">\\1</span></span>"))

            (buffer-string)
            )
          )

    (delete-region p1 p2)
    (insert mystr)
    )
  )

Here's the text to test on:

... Alt+T ...

doesn't matter what i set case-replace to, the result is:

... <Span Class="Kbd"><Span Class="Key">Alt</Span>+<Span
Class="Key">T</Span></Span> ...

Note the cap in “Span”, but i really want “span”.
I spent a hour debugging this.
Am i missing something?

Thanks.

  Xah
∑ http://xahlee.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]