unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Ye Wenbin" <wenbinye@gmail.com>
Subject: how to scroll other buffer to beginning
Date: Thu, 13 Jul 2006 13:39:40 +0800	[thread overview]
Message-ID: <op.tcl4oes552p72k@localhost.localdomain> (raw)

I wrote a perl script to count directory size, when I write this function,
I found that when the "*Shell Command Output*" buffer is displayed, the  
buffer
can't scroll to beginning. How to avoid it?

(defun ywb-dired-count-dir-size ()
   (interactive)
   (let ((dir (dired-get-filename nil t))
         proc)
     (when (file-directory-p dir)
       (with-current-buffer (get-buffer-create "*Shell Command Output*")
         (erase-buffer)
         (setq proc
               (start-process-shell-command "dirsize" (current-buffer)
                                            "/home/ywb/bin/dirsize " dir))
         (while (eq (process-status proc) 'run)
           (sleep-for 0 100)
           (message "%s" (process-status proc)))
         (display-buffer (current-buffer) t)
         (beginning-of-buffer)))))
(define-key dired-mode-map " " 'ywb-dired-count-dir-size)

this is my perl script for test:
#!/usr/bin/perl -w
# dirsize --- Caculate directory size
# Last modify Time-stamp: <Ye Wenbin 2006-07-11 16:23:15>
# Version: v 0.0 2006/07/06 06:03:53
# Author: Ye Wenbin <wenbinye@163.com>
use strict;
use warnings;
use File::Find;
my $dir = shift;
exit unless -d $dir;
printf "$dir size: %s\n", dirsize($dir);
sub dirsize {
     my $dir = shift;
     my $kb = 1024;
     my $mb = 1024*1024;
     my $total = 0;
     my $count = sub {
         if (-f $_) {
             $total += -s $_;
         }
     };
     find($count, $dir);
     if ($total > $mb) {
         return sprintf("%.2f", $total/$mb)." M";
     }
     else {
         return sprintf("%.2f", $total/$kb)." K";
     }
}


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

             reply	other threads:[~2006-07-13  5:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-13  5:39 Ye Wenbin [this message]
2006-07-13 15:16 ` how to scroll other buffer to beginning Kevin Rodgers

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=op.tcl4oes552p72k@localhost.localdomain \
    --to=wenbinye@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).