From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?iso-8859-1?q?R=F6hler?= Newsgroups: gmane.emacs.help Subject: Towards a large file mode, slowness Date: Wed, 2 Jul 2008 14:14:02 +0200 Message-ID: <200807021414.03497.andreas.roehler@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1215000569 18472 80.91.229.12 (2 Jul 2008 12:09:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Jul 2008 12:09:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 02 14:10:12 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KE1A2-0001gn-AM for geh-help-gnu-emacs@m.gmane.org; Wed, 02 Jul 2008 14:10:12 +0200 Original-Received: from localhost ([127.0.0.1]:39836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KE19A-0003vw-Ng for geh-help-gnu-emacs@m.gmane.org; Wed, 02 Jul 2008 08:09:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KE18s-0003v0-Lt for help-gnu-emacs@gnu.org; Wed, 02 Jul 2008 08:08:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KE18o-0003rV-IG for help-gnu-emacs@gnu.org; Wed, 02 Jul 2008 08:08:58 -0400 Original-Received: from [199.232.76.173] (port=59300 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KE18o-0003rI-EY for help-gnu-emacs@gnu.org; Wed, 02 Jul 2008 08:08:54 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.174]:55213) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KE18n-0006fZ-Rl for help-gnu-emacs@gnu.org; Wed, 02 Jul 2008 08:08:54 -0400 Original-Received: from noname (p54BE8D96.dip0.t-ipconnect.de [84.190.141.150]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1KE18b3JnU-0002WL; Wed, 02 Jul 2008 14:08:42 +0200 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) Content-Disposition: inline X-Provags-ID: V01U2FsdGVkX180AR09WGSblLQvIibdPDYybSXqK4c1Cp6TlB9 luy3bKGAA1NVIPyxd6lOamHbuA4cOYQnuKmTO0JRchVU7QIUyI Vj//stI5s7npOBhVTxt9Q== X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:55194 Archived-At: Hi, dealing with large files, exceeding emacs capabilities, idea is to use `sed' to deliver subsequent chunks. This seems possible if the files structur is line-separated,=20 if no single line exceeds max volume. =46or example that way: sed -n '111,130p' ein.txt In the real program below the range is given by var `ltm-start-line' and (+ ltm-start-line ltm-line-step) If I call `sed' from within an Emacs-Shell, its quite fast regardless of the files volume. Using `shell-command-to-string' or `call-process' as the program below, it's slowed down considerably. Any ideas how to avoid this? Thanks Andreas R=F6hler ;;; large-text-mode.el --- Loads large line-separated files=20 ;; Copyright (C) 2008 Andreas Roehler ;; Author: vorname nachname ;; Keywords: wp ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;;=20 ;;; Code: ;; sed -n '111,130p' ein.txt (require 'ffap) (setq ltm-line-step 2) (setq ltm-start-line 1) (defvar ltm-file nil) (defun ltm-find-file (&optional ltm-start-line ltm-file) (interactive "p") (let* ((file (cond (ltm-file ltm-file) ((featurep 'ffap) (ffap-guesser)) (read-from-minibuffer "File: "))) (buffer (file-name-nondirectory file))) (ltm-find-file-intern file buffer (concat "sed -n "(number-to-string=20 ltm-start-line)"," (number-to-string (+ ltm-start-line ltm-line-step))"p ")= )) (setq ltm-start-line ltm-start-line) (setq ltm-file ltm-file)) (defun ltm-find-file-intern (file buffer sedcommand) (set-buffer (get-buffer-create buffer)) (erase-buffer) (switch-to-buffer buffer) ;; Two alternatives ;; (call-process "/bin/bash" file buffer t "-c" sedcommand)=20 (insert (shell-command-to-string (concat sedcommand file))) ) (defun ltm-next () " " (interactive) (setq ltm-start-line (+ ltm-start-line ltm-line-step)) (ltm-find-file ltm-start-line ltm-file)) (provide 'large-text-mode) ;;; large-text-mode.el ends here