From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang Jenkner Newsgroups: gmane.emacs.bugs Subject: bug#13575: 24.1; dired-mark-sexp misparses directory contents Date: Mon, 28 Jan 2013 20:19:17 +0100 Message-ID: <85k3qxxg7v.fsf@iznogoud.viz> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1359401144 23621 80.91.229.3 (28 Jan 2013 19:25:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Jan 2013 19:25:44 +0000 (UTC) Cc: 13575@debbugs.gnu.org To: Sean McAfee Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 28 20:26:03 2013 Return-path: Envelope-to: geb-bug-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 1TzuL7-0008DM-T9 for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Jan 2013 20:25:58 +0100 Original-Received: from localhost ([::1]:42887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzuKp-0001uV-Vf for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Jan 2013 14:25:39 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzuKn-0001uP-Nm for bug-gnu-emacs@gnu.org; Mon, 28 Jan 2013 14:25:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TzuKm-0006Vv-0Y for bug-gnu-emacs@gnu.org; Mon, 28 Jan 2013 14:25:37 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzuKl-0006Vp-U9 for bug-gnu-emacs@gnu.org; Mon, 28 Jan 2013 14:25:35 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TzuLC-0001G9-6g for bug-gnu-emacs@gnu.org; Mon, 28 Jan 2013 14:26:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Wolfgang Jenkner Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Jan 2013 19:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13575 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13575-submit@debbugs.gnu.org id=B13575.13594011594832 (code B ref 13575); Mon, 28 Jan 2013 19:26:02 +0000 Original-Received: (at 13575) by debbugs.gnu.org; 28 Jan 2013 19:25:59 +0000 Original-Received: from localhost ([127.0.0.1]:52869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TzuL8-0001Ft-QV for submit@debbugs.gnu.org; Mon, 28 Jan 2013 14:25:59 -0500 Original-Received: from mx07.lb01.inode.at ([62.99.145.7]:27116 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TzuL4-0001Fi-Qx for 13575@debbugs.gnu.org; Mon, 28 Jan 2013 14:25:57 -0500 Original-Received: from [91.119.206.19] (port=13730 helo=iznogoud.viz) by smartmx-07.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TzuKc-0004YL-Es; Mon, 28 Jan 2013 20:25:26 +0100 Original-Received: from wolfgang by iznogoud.viz with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1TzuKb-0000ct-0d; Mon, 28 Jan 2013 20:25:25 +0100 User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (berkeley-unix) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70410 Archived-At: On Mon, Jan 28 2013, Sean McAfee wrote: > I recently wanted to mark all zero-size files in a dired buffer. I > found that dired-mark-sexp seemed to be just what I needed, but when I > invoked it with the expression (= size 0), I found that it marked every > file, even those of nonzero size. > > Here's a test directory I set up: > > /home/mcafee/test: > total used in directory 28 available 102379756 > drwxrwxr-x 2 mcafee mcafee 4096 Jan 27 18:31 . > drwxr-xr-x 44 mcafee mcafee 12288 Jan 27 18:31 .. > -rw-rw-r-- 1 mcafee mcafee 8 Jan 27 18:31 bar > -rw-rw-r-- 1 mcafee mcafee 12 Jan 27 18:31 baz > -rw-rw-r-- 1 mcafee mcafee 4 Jan 27 18:31 foo > > In this directory, I ran dired-mark-sexp with the following expression, > intended to exercise all of the available symbols: > > (progn (message > "name=%s;inode=%s;s=%s;mode=%s;nlink=%s;uid=%s;gid=%s;size=%s;time=%s;sym=%s" > name inodes mode nlink uid gid size time sym) nil) -------^ inode s I think you have to customize dired-listing-switches to something like "-alis" so that inode number and block count are actually shown in the buffer. > Here are the messages that were produced: > name=.;inode=0;s=0;mode=drwxrwxr-x;nlink=2;uid=mcafee;gid=2;size=0;time= > mcafee 4096 Jan 27 18:31;sym= > name=..;inode=0;s=0;mode=drwxr-xr-x;nlink=44;uid=mcafee;gid=44;size=0;time= > mcafee 12288 Jan 27 18:31;sym= [...] > Clearly, the "time" variable includes more of the directory listing than > it should, and "size" is incorrectly set to zero for all files, as I > originally noticed. That's a bug in dired-x (wrong use of the somewhat awkward directory-listing-before-filename-regexp variable). As a first attempt to fix this I propose the following barely tested patch. Wolfgang diff --git a/lisp/dired-x.el b/lisp/dired-x.el index a2c1303..73eebd1 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -1449,8 +1449,7 @@ to mark all zero length files." ;; to nil or the appropriate value, so they need not be initialized. ;; Moves point within the current line. (dired-move-to-filename) - (let (pos - (mode-len 10) ; length of mode string + (let ((mode-len 10) ; length of mode string ;; like in dired.el, but with subexpressions \1=inode, \2=s: (dired-re-inode-size "\\s *\\([0-9]*\\)\\s *\\([0-9]*\\) ?")) (beginning-of-line) @@ -1472,22 +1471,18 @@ to mark all zero length files." ;; Karsten Wenger fixed uid. (setq uid (buffer-substring (1+ (point)) (progn (forward-word 1) (point)))) - (re-search-forward directory-listing-before-filename-regexp) - (goto-char (match-beginning 1)) - (forward-char -1) - (setq size (string-to-number - (buffer-substring (save-excursion - (backward-word 1) - (setq pos (point))) - (point)))) - (goto-char pos) - (backward-word 1) + (re-search-forward directory-listing-before-filename-regexp) + (re-search-backward directory-listing-before-filename-regexp) + (forward-word 1) + (save-excursion + (setq size (string-to-number + (buffer-substring (point) (progn (backward-word 1) + (point)))) + gid (buffer-substring (1- (point)) (progn (backward-word 1) + (point))))) ;; if no gid is displayed, gid will be set to uid ;; but user will then not reference it anyway in PREDICATE. - (setq gid (buffer-substring (save-excursion - (forward-word 1) (point)) - (point)) - time (buffer-substring (match-beginning 1) + (setq time (buffer-substring (1+ (point)) (1- (dired-move-to-filename))) name (buffer-substring (point) (or