From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: replacing endline Date: Thu, 20 Apr 2006 23:38:10 GMT Organization: EarthLink Inc. -- http://www.EarthLink.net Message-ID: References: <1145492327.354125.133060@j33g2000cwa.googlegroups.com> <87lku1t3fn.fsf@gmail.com> <7efyk8pxjz.fsf@ada2.unipv.it> <87acagux25.fsf@gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1145576454 32057 80.91.229.2 (20 Apr 2006 23:40:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2006 23:40:54 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 21 01:40:53 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FWilR-000137-4Y for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Apr 2006 01:40:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FWilQ-0002av-Aq for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2006 19:40:44 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!207.69.154.102.MISMATCH!elnk-atl-nf2!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread1.news.atl.earthlink.net.POSTED!0847253b!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 70 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Original-NNTP-Posting-Host: 4.159.166.67 Original-X-Complaints-To: abuse@earthlink.net Original-X-Trace: newsread1.news.atl.earthlink.net 1145576290 4.159.166.67 (Thu, 20 Apr 2006 16:38:10 PDT) Original-NNTP-Posting-Date: Thu, 20 Apr 2006 16:38:10 PDT Original-Xref: shelby.stanford.edu gnu.emacs.help:138909 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:34527 Archived-At: "Fredrik Bulow" wrote in message 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.