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

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

Re: replacing endline


From: B. T. Raven
Subject: Re: replacing endline
Date: Thu, 20 Apr 2006 23:38:10 GMT

"Fredrik Bulow" <kaliumfredrik@gmail.com> wrote in message
87acagux25.fsf@gmail.com">news:87acagux25.fsf@gmail.com...
> >> I don't see why this behavior shouldn't be labeled as a bug.
> >
> >if you label that behavior as a bug, then you have introduced two
> >"bugs", not just one.  the first bug is in your mental model of how
> >emacs should work, and the second, the one labeled as suggested.  if
> >you pre-emptively fix the first bug, perhaps the second bug will, as a
> >result, vanish as well.
> >
> >applying the above thought process to various behaviors, you may
> >be able to find and remove many bugs in the future.  good luck!
> >
> >thi
>
> Thanks for that totally uncalled for insult. Of course, any bug can be
> removed by changing your expectations on how a program should behave
> to the way a program actually behaves. "It's not a bug that something
> crashes, it is suppose to crash, and how do I know that? Well, I tried
> and it crashed!." Usually, if something behaves in an unexpected way I
> think it is a bug unless there is a good reason why the current
> behaviour makes more sense than what I expected. I was kind of hoping
> that someone would give me the good reason why there should be two
> different behaviours.
>
> So once again, what is the good reason that (query-replace "\n" "#")
> behave differenty than calling the same function with its keybinding
> and providing it interactively with the same arguments?
>
> /Fredrik

This is one of those wonderful instances where both you and Thi are right.
It is difficult for those far up on the mountainside to see what things
look like down here in the valley. Try playing around with  C-q C-j and
just C-j in *scratch* and in a text-mode buffer.
In
(query-replace "\n" "*")
the "/n" works the same way as it does in
 printf ("Hello World!\n");
It is one of two arguments of type string to the query-replace function
If you put the lines below into *scratch* and then evaluate the form, it
will find the invisible newlines rather than the characters ", \, n, "
M-% will only find those literal characters unless you input a newline as
C-q C-j. Press the n key instead of the space bar to inhibit replacement
with "*". After you play around with this for a while you will agree with
Thi, sort of, which is good enough.


(query-replace "\n" "*")




\n
"\n"
'("\n")

p.s. Remember M-x top-level and C-x n w. It's easy to get lost while
fooling around with C-j in an interactive lisp buffer. Its behaviour
depends on whether or not there are matched parentheses above the point
where it is invoked. I am pretty sure that C-q C-j is a synonym for the
Enter-Return key just about anywhere except inside interactive functions
like M-% and C-M-% where it produces an actual newline in the minibuffer..

("
")

Ed.



reply via email to

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