Note: In case you're unfamiliar with CamelCase, it's a convention for variable names originally popularized by the X Window System. Earlier conventions for C and C++ used "_" as a word delimiter within variable names. Lisp used "-" instead of "_". CamelCase, so-called because the capital letters in the middle of the word form humps like those on a camel's back, uses capital letters to indicate the beginning of a new word. So, the C-style variable name find_char_in_string, or Lisp-style variable name find-char-in-string, in CamelCase is findCharInString.The purpose of this part of the macro is to turn CamelCase into space-separated words.
So, if the narrowed portion of the buffer contains:M-< ;; Go to beginning of narrowed buffer
M-x replace-regexp RET
[A-Z] RET ;; Find any capital letter
C-q SPC \& RET ;; Replace it with a space followed by itself
M-< ;; Go to beginning of narrowed buffer
C-d ;; Delete the unwanted space before the first letter
after running this portion of the macro, it should contain:"JohnJacobJingleheimerschmidt"
Instead, when run in Emacs 23, the result is:"John Jacob Jingleheimerschmidt"
which is exactly what you'd expect if the M-x replace-regexp failed to do the replacement that it should have. But since I know that sometimes a replace command works the second time after failing to work the first time, I modified that portion of the macro to do the replace twice:"ohnJacobJingleheimerschmidt"
Now, if the replace were working the first time, applying it again would produce the undesired result:M-< ;; Go to beginning of narrowed buffer
M-x replace-regexp RET
[A-Z] RET ;; Find any capital letter
C-q SPC \& RET ;; Replace it with a space followed by itself
M-< ;; Go to beginning of narrowed buffer
M-x replace-regexp RET
[A-Z] RET ;; Find any capital letter
C-q SPC \& RET ;; Replace it with a space followed by itself
M-< ;; Go to beginning of narrowed buffer
C-d ;; Delete the unwanted space before the first letter
Instead, it produces:" John Jacob Jingleheimerschmidt"
Does anybody here have any idea what's going wrong here?"John Jacob Jingleheimerschmidt"
Mark RosenthalP.S. - One further clue: In the older version of Emacs (21.3) I've noticed that at those times when the replace fails to work, if I repeat the replace command with C-x ESC ESC, the minibuffer shows:
m...@arlsoft.com
where sss and eee are integers that are supposed to indicate the beginning and end characters of the region to operate on, but when the replace has failed, sss and eee specify a small subset of the region.(replace-regexp "[A-Z]" " \\&" nil sss eee)
I'm not surprised that you can't reproduce it. It's so unpredictable that it reminds me of an assembly language bug I diagnosed many years ago where the code turned out to be making a critical decision based on data it fetched from an uninitialized memory location. In the case of this bug, the state of memory could depend on every keystroke I've typed since I started Emacs, the contents of every file it's opened, etc.I can't reproduce that misbehavior on w32 ver 23.1 Both in *scratch* (lisp mode) and a junk file in text mode I get: John Jacob Jingleheimerschmidt " John Jacob Jingleheimerschmidt" " John Jacob Jingleheimerschmidt" John Jacob Jingleheimerschmidt John Jacob Jingleheimerschmidt where the second and third lines were originally camel-case in quotes. I did assign the macro to a keychord with C-xC-kb Ed
Mark
In case ni...@nihilo.net is reading this list, do you have any idea why your mailserver is rejecting emails addressed to you? Is there an alternate email address I can mail you at?This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: ni...@nihilo.net SMTP error from remote mail server after RCPT TO:<ni...@nihilo.net>: host mailserver.nihilo.net [213.171.216.114]: 550 <ni...@nihilo.net>: Recipient address rejected: User unknown in virtual mailbox table
Mark Rosenthal
m...@arlsoft.com
I assume something like Valgrind has been applied to Emacs … and it’s clean.
Cheers,
Mark