From: Wolfgang Jenkner <wjenkner@inode.at>
To: Sean McAfee <eefacm@gmail.com>
Cc: 13575@debbugs.gnu.org
Subject: bug#13575: 24.1; dired-mark-sexp misparses directory contents
Date: Mon, 28 Jan 2013 20:19:17 +0100 [thread overview]
Message-ID: <85k3qxxg7v.fsf@iznogoud.viz> (raw)
In-Reply-To: <CANan03ZWsC5ezDGosg+PNU9QWS_TFH7DG-i7S6LvBwmUFUZyxw@mail.gmail.com>
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 <kw@cis.uni-muenchen.de> 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
next prev parent reply other threads:[~2013-01-28 19:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-28 2:49 bug#13575: 24.1; dired-mark-sexp misparses directory contents Sean McAfee
2013-01-28 19:19 ` Wolfgang Jenkner [this message]
2013-01-29 5:35 ` Wolfgang Jenkner
2015-06-26 12:54 ` Wolfgang Jenkner
2015-07-06 13:08 ` Wolfgang Jenkner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85k3qxxg7v.fsf@iznogoud.viz \
--to=wjenkner@inode.at \
--cc=13575@debbugs.gnu.org \
--cc=eefacm@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.