From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: dired and ls Date: Sat, 20 Feb 2016 18:25:24 +1100 Message-ID: <87k2lzdesb.fsf@gnus.org> References: <87povs41xg.fsf@gnus.org> <87bn7c3yms.fsf@gnus.org> <87mvqvewk6.fsf_-_@gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1455953168 15337 80.91.229.3 (20 Feb 2016 07:26:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Feb 2016 07:26:08 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 20 08:25:57 2016 Return-path: Envelope-to: ged-emacs-devel@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 1aX1vQ-0006Ie-R4 for ged-emacs-devel@m.gmane.org; Sat, 20 Feb 2016 08:25:57 +0100 Original-Received: from localhost ([::1]:58852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX1vP-00040i-TS for ged-emacs-devel@m.gmane.org; Sat, 20 Feb 2016 02:25:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX1vM-00040a-Sn for emacs-devel@gnu.org; Sat, 20 Feb 2016 02:25:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aX1vL-0005qk-Vl for emacs-devel@gnu.org; Sat, 20 Feb 2016 02:25:52 -0500 Original-Received: from hermes.netfonds.no ([80.91.224.195]:36088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX1vL-0005qe-P2 for emacs-devel@gnu.org; Sat, 20 Feb 2016 02:25:51 -0500 Original-Received: from cpe-60-225-211-161.nsw.bigpond.net.au ([60.225.211.161] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aX1uz-0000Hv-F4 for emacs-devel@gnu.org; Sat, 20 Feb 2016 08:25:30 +0100 In-Reply-To: (John Wiegley's message of "Fri, 19 Feb 2016 22:19:58 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-MailScanner-ID: 1aX1uz-0000Hv-F4 MailScanner-NULL-Check: 1456557930.37491@WtZgVU3YN5LasVC2dcx76Q X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.224.195 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:200281 Archived-At: John Wiegley writes: > The /bin/ls process is asynchronous, so a really long "ls -R" listing doesn't > need to block Emacs, does it? That's true. With "ls" the opportunity for async behaviour is greater. I don't think dired currently is async, but it could be... >> Hm... and there are a lot of functions in Emacs that only wants to know the >> file name and whether it's a directory or not... I mean, basically every >> file prompting function only needs that info... > > Are you also suggesting another improvement (Rubs hands expectantly)? :-) > Or does this follow from the above, in which case I missed the > implication... I was thinking out loud. :-) I'm looking at file_name_completion now, and the basic loop is: for (struct dirent *dp; (dp = read_dirent (d, dirname)); ) { [...] if (file_name_completion_stat (fd, dp, &st) < 0) continue; directoryp = S_ISDIR (st.st_mode) != 0; and that seems to be the only data used from the stat call. So a `(directory-files-with-attributes DIR ... FILE-OR-DIR-ONLY-P)' function seems like it would speed things up a lot if you hit TAB while looking for a file in a large directory (on Linux and BSD). The function could have two modes -- one where it only returned the file name + dirp, and one where it returns full attributes. The former case would be just a readdir loop, so it would be very fast, while the second would need to stat every file, so it would... not. `dired' would typically need the latter, while file completion would need the former. Modulo that I'm reading the code right. The completion code is terra incognito to me. :-) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no