From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Add M-x occur to the menu-bar Date: 07 Feb 2004 17:39:18 -0500 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <3F69E6FF.9050702@yahoo.com> <4n8yjto16h.fsf@collins.bwh.harvard.edu> <4nisixjibl.fsf@collins.bwh.harvard.edu> <20040127230323.GB5407@fencepost> <4n7jzc919v.fsf@collins.bwh.harvard.edu> <4nn085i7nl.fsf@collins.bwh.harvard.edu> <4noese37h0.fsf@collins.bwh.harvard.edu> <4nbrodxwqm.fsf@collins.bwh.harvard.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1076193990 8778 80.91.224.253 (7 Feb 2004 22:46:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 7 Feb 2004 22:46:30 +0000 (UTC) Cc: Ted Zlatanov , emacs-devel@gnu.org, "Kim F. Storm" Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Feb 07 23:46:23 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ApbDT-0005Hd-00 for ; Sat, 07 Feb 2004 23:46:23 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ApbDT-0007cb-00 for ; Sat, 07 Feb 2004 23:46:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Apb7o-0008U8-HA for emacs-devel@quimby.gnus.org; Sat, 07 Feb 2004 17:40:32 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1Apb7i-0008Rk-Ju for emacs-devel@gnu.org; Sat, 07 Feb 2004 17:40:26 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1Apb7B-00088F-K0 for emacs-devel@gnu.org; Sat, 07 Feb 2004 17:40:24 -0500 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Apb6g-0007wa-3W; Sat, 07 Feb 2004 17:39:22 -0500 Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 39A4B212AE; Sat, 7 Feb 2004 17:39:19 -0500 (EST) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 0325D8C708; Sat, 7 Feb 2004 17:39:18 -0500 (EST) Original-To: David Kastrup In-Reply-To: Original-Lines: 29 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-1.428, requis 5, BAYES_20 -1.43) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:19791 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19791 >> > (save-excursion >> > (set-buffer buffer) >> >> Also known as (with-current buffer buffer > It's not the same if buffer is already selected. In that case the > first version restores the cursor position afterwards and the second > doesn't. Indeed, it's not 100% equivalent. My experience is that in practice, in 98% of the cases, you can replace the first with the second, as for the remaining 2% it's probably equally split between cases where it would introduce a bug and cases where it makes an existing bug a bit more obvious to the programmer. This last case is when people do for example: (save-excursion (set-buffer foo) (re-search-forward "bar") (match-string 1)) where they should have done (with-current-buffer foo (save-excursion (re-search-forward "bar") (match-string 1))) -- Stefan