From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: How to know is a buffer is a temporary one? Date: Mon, 29 Jul 2013 22:06:58 +0200 Organization: Sebastien Vauban Message-ID: <86fvuxf7vh.fsf@somewhere.org> References: <86k3k975fj.fsf@somewhere.org> <861u6h42el.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1375128890 8028 80.91.229.3 (29 Jul 2013 20:14:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Jul 2013 20:14:50 +0000 (UTC) Cc: help-gnu-emacs-mXXj517/zsQ@public.gmane.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Mon Jul 29 22:14:50 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V3tqD-0006vn-Na for geh-help-gnu-emacs@m.gmane.org; Mon, 29 Jul 2013 22:14:49 +0200 Original-Received: from localhost ([::1]:60431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3tqD-0008E1-7R for geh-help-gnu-emacs@m.gmane.org; Mon, 29 Jul 2013 16:14:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3tj4-0000aV-3Q for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 29 Jul 2013 16:07:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3tiw-0000DP-Oz for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 29 Jul 2013 16:07:26 -0400 Original-Received: from eline.schedom-europe.net ([193.109.184.70]:46779) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1V3tiw-0000DB-Ft for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 29 Jul 2013 16:07:18 -0400 Original-Received: (qmail 12721 invoked by uid 507); 29 Jul 2013 22:07:17 +0200 Original-Received: from ip-83-101-44-240.customer.schedom-europe.net (HELO MUNDANEUM.) (83.101.44.240) by eline.schedom-europe.net with AES128-SHA encrypted SMTP; 29 Jul 2013 22:07:10 +0200 User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (windows-nt) X-Url: Under construction... X-Archive: encrypt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 193.109.184.70 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:92519 Archived-At: Stefan Monnier wrote: > Maybe you're better off trying to define "useful buffer" for your > particular case. E.g. maybe check `buffer-file-name'. Then a version checking with a regexp seems slightly more efficient (1.19 s vs 1.14 s) than the one checking the name with a substring: --8<---------------cut here---------------start------------->8--- (setq i 0) ;; 1.19 s on i7 on mains ;; (while (< i 1000) ;; (message "%s" i) ;; (if (equal (substring (buffer-name) 0 2) " *") ;; (message "this is a temp buffer") ;; (message "this is not a temp buffer")) ;; (setq i (+ i 1))) ;; 1.14 s on i7 on mains (while (< i 1000) (message "%s" i) (if (string-match "^ \*" (buffer-name)) (message "this is a temp buffer") (message "this is not a temp buffer")) (setq i (+ i 1))) --8<---------------cut here---------------end--------------->8--- Best regards, Seb -- Sebastien Vauban