From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master e820f16: Added file-tree-walk to files.el. Date: Wed, 03 Dec 2014 10:31:00 -0500 Message-ID: References: <20141203142859.24393.98673@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417620746 12794 80.91.229.3 (3 Dec 2014 15:32:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Dec 2014 15:32:26 +0000 (UTC) Cc: "Eric S. Raymond" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 03 16:32:17 2014 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 1XwBub-0000ah-4g for ged-emacs-devel@m.gmane.org; Wed, 03 Dec 2014 16:32:17 +0100 Original-Received: from localhost ([::1]:42111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwBua-0002Kt-J6 for ged-emacs-devel@m.gmane.org; Wed, 03 Dec 2014 10:32:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwBtW-0001B6-7k for emacs-devel@gnu.org; Wed, 03 Dec 2014 10:31:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwBtN-0001MB-T4 for emacs-devel@gnu.org; Wed, 03 Dec 2014 10:31:10 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:54197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwBtN-0001M5-Pq for emacs-devel@gnu.org; Wed, 03 Dec 2014 10:31:01 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjsPAOwQflRMCqTq/2dsb2JhbABbgweDYIVaxR0EAgKBJBcBAQEBAQF8hAMBAQRWIxALNBIUGA2Id9ZZAQEBAQYBAQEBHpBvBxaEMgWLAZIxj3OCCoF4hBkhgncBAQE X-IPAS-Result: AjsPAOwQflRMCqTq/2dsb2JhbABbgweDYIVaxR0EAgKBJBcBAQEBAQF8hAMBAQRWIxALNBIUGA2Id9ZZAQEBAQYBAQEBHpBvBxaEMgWLAZIxj3OCCoF4hBkhgncBAQE X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="99461908" Original-Received: from 76-10-164-234.dsl.teksavvy.com (HELO pastel.home) ([76.10.164.234]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 Dec 2014 10:31:00 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 4033643B6; Wed, 3 Dec 2014 10:31:00 -0500 (EST) In-Reply-To: (Eric S. Raymond's message of "Wed, 03 Dec 2014 14:28:59 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:178727 Archived-At: > +(defun file-tree-walk (dir action &rest args) > + "Walk DIR executing ACTION. Each call gets as arguments DIR, a file path, The first line should be self-sufficient, so better add a newline after the ".". > +and optional ARGS. The ACTION is applied to each subdirectory ^^ Use two spaces to separate sentences. > +before descending into it, and if nil is returned at that point > +the descent will be prevented. Directory entries are sorted with > +string-lessp" ^^^ Don't forget to punctuate your docstrings. I think C-u M-x checkdoc-current-buffer RET would have caught all those. We really should try and setup flymake.el automatically for Elisp buffers to flag those things on-the-fly. > + (cond ((file-directory-p dir) > + (or (char-equal ?/ (aref dir (1- (length dir)))) > + (setq dir (file-name-as-directory dir))) > + (let ((lst (directory-files dir nil nil t)) Experience taught me that file-name-all-completions followed by testing the presence of a trailing "/" is *much* faster because calling file-directory-p on each entry ends up costly. I got this trick from Eshell's code for ** globbing, where the speed difference was a factor 10 when I tested it. Stefan