Subject: 24.5; Emacs blocked on long lines.

From: Oleksandr Gavenko <[email-masked]>
Date: Fri, 11 Dec 2015 17:54:31 +0200

It is usual for me to open files with large lines in Emacs.

Some times this was log, or executable, or dump.

But usually this was minified .js or .json file.

And only thing I can do is to live with slowness or to kill Emacs and may be
clean corresponding desktop-mode entries for *bad* file.

I contribute piece to:

  http://emacs.stackexchange.com/questions/598/how-do-i-handle-files-with-extremely-long-lines

Here it is:

  (setq line-number-display-limit large-file-warning-threshold)
  (setq line-number-display-limit-width 200)

  (defun my--is-file-large ()
    "If buffer too large and my cause performance issue."
    (< large-file-warning-threshold (buffer-size)))

  (define-derived-mode my-large-file-mode fundamental-mode "LargeFile"
    "Fixes performance issues in Emacs for large files."
    ;; (setq buffer-read-only t)
    (setq bidi-display-reordering nil)
    (jit-lock-mode nil)
    (buffer-disable-undo)
    (set (make-variable-buffer-local 'global-hl-line-mode) nil)
    (set (make-variable-buffer-local 'line-number-mode) nil)
    (set (make-variable-buffer-local 'column-number-mode) nil) )

  (add-to-list 'magic-mode-alist (cons #'my--is-file-large #'my-large-file-mode))

But it is for a large files (but help me in many case because files with long
lines usually also themselves big). I didn't investigate how to make test for long
lines jet.

Even with those settings some files (usually minified .js libraries or .json
files) froze Emacs. I think due to js-mode, but...

I would like to hear solution for long line issue or a way to detect long
lines and prevent file from opening (or decide to risk if lines is not toooo
long).

My point instead of restarting Emacs daemon - safely warn about long lines so
I have a chance to preserve my Emacs session before Emacs die.

================================================================

(info "(emacs) Visiting") say about large files:

     If you try to visit a file larger than ‘large-file-warning-threshold’
  (the default is 10000000, which is about 10 megabytes), Emacs asks you
  for confirmation first.  You can answer ‘y’ to proceed with visiting the
  file.  Note, however, that Emacs cannot visit files that are larger than
  the maximum Emacs buffer size, which is limited by the amount of memory
  Emacs can allocate and by the integers that Emacs can represent (*note
  Buffers::).  If you try, Emacs displays an error message saying that the
  maximum buffer size has been exceeded.

User warned about large files. But there are nothing about long lines in
manual!

I would like to see corresponding entry in manual about long line handling:

  If you try to scroll to line longer then `long-line-warning-threshold' (the
  default is 10000, which is about 100 lines long), Emacs asks you for
  confirmation first.

In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.2)
 of 2015-10-24 on trouble, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11702000
System Description:	Debian GNU/Linux testing (stretch)

Configured using:
 `configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fstack-protector-strong -Wformat -Werror=format-security -Wall'
 CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-z,relro'

Important settings:
  value of $LC_TIME: en_DK.utf8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

-- 
Best regards!