|
From: | Sebastien Vauban |
Subject: | Re: How to know is a buffer is a temporary one? |
Date: | Mon, 29 Jul 2013 22:06:58 +0200 |
User-agent: | Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (windows-nt) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |