all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* does with-temp-buffer respect case-replace?
@ 2008-10-29 13:41 Xah
  2008-10-29 14:49 ` Seweryn Kokot
  0 siblings, 1 reply; 2+ messages in thread
From: Xah @ 2008-10-29 13:41 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-29 14:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29 13:41 does with-temp-buffer respect case-replace? Xah
2008-10-29 14:49 ` Seweryn Kokot

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.