unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alexander Shukaev <emacs@Alexander.Shukaev.name>
To: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Cc: mithraeum <mithraeum@protonmail.com>
Subject: Re: Performance degradation from long lines
Date: Fri, 26 Oct 2018 17:34:02 +0200	[thread overview]
Message-ID: <3717982b-8f1b-2e2b-b213-59aeb62bbb93@Alexander.Shukaev.name> (raw)
In-Reply-To: <MFfgHOf5wGUxTqL_Zl9dh1SXan5VhYW7U4cbeWaurXpou1xrRnQeN6LAjKU3GxUdS2TdJ3XqNuyQheieSXYktLspNlPnQX4BdCDEN3J6jWU=@protonmail.com>

Modes like `so-long' are not useful at all to resolve these issues 
(because, example it does not prevent the initial activation of the 
offending major mode, but rather only disables it afterwards).  The only 
way I found to reliably mitigate the problem in an semi-automated manner 
consists of two parts.  First,

(require 'longlines)
;;
(defcustom global-longlines-threshold
   line-number-display-limit-width
   "\
Maximum line length permitted before applying `longlines-mode'.

See `global-longlines-p'."
   :group 'longlines
   :type 'integer)
;;
(defun global-longlines-p
     (&optional buffer)
   "\
Test all lines of buffer BUFFER for `global-longlines-threshold'.

Return t if `global-longlines-threshold' is exceeded."
   (with-current-buffer (or buffer (current-buffer))
     (when (integerp global-longlines-threshold)
       (save-restriction
         (widen)
         (save-excursion
           (goto-char (point-min))
           (let ((inhibit-field-text-motion t))
             (catch 'break
               (while (not (eobp))
                 (when (> (- (line-end-position 1) (point))
                          global-longlines-threshold)
                   (throw 'break t))
                 (forward-line 1)))))))))
;;
;;;###autoload
(defun turn-on-longlines-mode-maybe ()
   (interactive)
   (when (global-longlines-p)
     (longlines-mode)))
;;
;;;###autoload
(define-globalized-minor-mode global-longlines-mode longlines-mode
   turn-on-longlines-mode-maybe
   :group 'longlines)
;;
(provide 'global-longlines)

and then configure

(add-hook 'after-init-hook #'global-longlines-mode)

Secondly,

(defgroup inhibit-set-auto-mode
   nil
   "Inhibit `set-auto-mode'."
   :group 'files
   :prefix 'inhibit-set-auto-mode-)
;;
(defcustom inhibit-set-auto-mode-functions
   nil
   "\
List of functions to be called to try to inhibit `set-auto-mode'.

Only used by `inhibit-set-auto-mode'.  If one of them returns
non-nil, inhibit `set-auto-mode' and the rest are not called."
   :group 'inhibit-set-auto-mode
   :type 'hook)
;;
(defun inhibit-set-auto-mode--around-advice
     (function &rest ...)
   (if (run-hook-with-args-until-success 'inhibit-set-auto-mode-functions)
       (let (enable-local-variables
             interpreter-mode-alist
             magic-mode-alist
             auto-mode-alist
             magic-fallback-mode-alist)
         (apply function ...))
     (apply function ...)))
;;
;;;###autoload
(define-minor-mode inhibit-set-auto-mode
   "\
Toggle inhibiting `set-auto-mode'.

With a prefix argument ARG, enable the mode if ARG is positive,
and disable it otherwise.  If called from Lisp, enable the mode
if ARG is omitted or nil.

See `inhibit-set-auto-mode-functions'."
   :group 'inhibit-set-auto-mode
   :global t
   (if inhibit-set-auto-mode
       (advice-add #'set-auto-mode
                   :around
                   #'inhibit-set-auto-mode--around-advice
                   '((depth . 100)))
     (advice-remove #'set-auto-mode
                    #'inhibit-set-auto-mode--around-advice)))
;;
(provide 'inhibit-set-auto-mode)

and then configure

(add-hook 'after-init-hook #'inhibit-set-auto-mode)

(defun inhibit-set-auto-mode-line-number-display-limit-function ()
   (and (integerp line-number-display-limit)
        (> (buffer-size) line-number-display-limit)))
(add-hook 'inhibit-set-auto-mode-functions
           #'inhibit-set-auto-mode-line-number-display-limit-function)

Regards,
Alexander



  parent reply	other threads:[~2018-10-26 15:34 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-24 23:59 Performance degradation from long lines mithraeum
2018-10-25  0:27 ` Stefan Monnier
2018-10-25 15:02   ` Eli Zaretskii
2018-10-25 15:37     ` Stefan Monnier
2018-10-25  3:26 ` Phil Sainty
2018-10-25 12:44   ` Stefan Monnier
2018-10-25 13:23     ` Eli Zaretskii
2018-10-25 13:30       ` Stefan Monnier
2018-10-25 15:08         ` Eli Zaretskii
2018-10-25 22:34           ` Phil Sainty
2018-10-26  6:36             ` Eli Zaretskii
2018-10-26 12:48             ` Stefan Monnier
2018-10-27  8:38               ` Phil Sainty
2018-10-27 15:32                 ` Drew Adams
2018-10-28  1:51                   ` Phil Sainty
2018-10-28  1:58                     ` Drew Adams
2018-10-27 22:18                 ` Stefan Monnier
2018-12-08 23:08                 ` Stefan Monnier
2018-12-09 14:40                   ` Phil Sainty
2018-12-30  4:07                     ` Phil Sainty
2019-01-12  1:03                       ` Phil Sainty
2019-01-12 11:08                         ` Eli Zaretskii
2019-03-10 10:22                           ` Phil Sainty
2019-03-10 12:58                             ` Eli Zaretskii
2019-03-10 13:36                               ` martin rudalics
2019-03-10 13:46                                 ` Eli Zaretskii
2019-03-10 23:16                                   ` Phil Sainty
2019-03-10 18:06                                 ` Stefan Monnier
2019-03-11  9:14                                   ` martin rudalics
2019-03-10 23:31                               ` Phil Sainty
2019-03-11  3:35                                 ` Eli Zaretskii
2019-03-11  3:48                                   ` Phil Sainty
2019-03-11 14:35                                     ` Eli Zaretskii
2018-10-26  1:46   ` mithraeum
2018-10-26  2:39     ` Phil Sainty
2018-10-26  2:58       ` mithraeum
2018-10-26  4:43         ` Phil Sainty
2018-10-26  5:54           ` mithraeum
2018-10-26  2:54     ` Phil Sainty
2018-10-26 15:18       ` Stefan Monnier
2018-10-27  3:10     ` Phil Sainty
2018-10-27 22:15       ` Stefan Monnier
2018-12-30  5:23         ` Phil Sainty
2018-10-28  2:03   ` Phil Sainty
2018-10-25 15:00 ` Eli Zaretskii
2018-10-25 17:18   ` Michael Heerdegen
2018-10-25 17:30     ` Eli Zaretskii
2018-10-26  0:59     ` mithraeum
2018-10-26  6:48       ` Eli Zaretskii
2018-10-26  7:00   ` Ihor Radchenko
2018-10-26  7:28     ` Eli Zaretskii
2018-10-26  7:36       ` Ihor Radchenko
2018-10-26  7:57         ` Eli Zaretskii
2018-10-26  8:05           ` Ihor Radchenko
2018-10-26  8:46             ` Eli Zaretskii
2018-10-26  8:58               ` Ihor Radchenko
2018-10-26  9:08                 ` Eli Zaretskii
2018-10-26  9:46                   ` Noam Postavsky
2018-10-26 12:35                     ` Eli Zaretskii
2018-10-26 15:09                 ` Stefan Monnier
2018-10-26  9:52               ` mithraeum
2018-10-26  8:05         ` mithraeum
2018-10-26 16:05     ` Gemini Lasswell
2018-10-31 13:05       ` Ihor Radchenko
2018-10-31 15:49         ` Eli Zaretskii
2018-10-25 17:53 ` Clément Pit-Claudel
2018-10-25 19:14   ` Eli Zaretskii
2018-10-25 19:17     ` Clément Pit-Claudel
2018-10-26  6:40 ` mithraeum
2018-10-26  7:26   ` Eli Zaretskii
2018-10-26  7:47     ` mithraeum
2018-10-26  8:30       ` Eli Zaretskii
2018-10-26  8:56         ` mithraeum
2018-10-26  9:06           ` Eli Zaretskii
2018-10-26 15:29           ` Stefan Monnier
2018-10-26 15:34 ` Alexander Shukaev [this message]
2018-10-26 16:18   ` Stefan Monnier
2018-10-26 16:50     ` Alexander Shukaev
2018-10-26 17:27       ` Stefan Monnier
2018-10-27  2:09   ` Phil Sainty
     [not found] <20190107065207.21793.53271@vcs0.savannah.gnu.org>
     [not found] ` <20190107065208.BA36C21736@vcs0.savannah.gnu.org>
2019-01-10 18:07   ` [Emacs-diffs] scratch/so-long 7273fb2: Add so-long library Stefan Monnier
2019-01-12  2:20     ` Phil Sainty
2019-01-12 15:11       ` Stefan Monnier
2019-04-14 13:09         ` Phil Sainty
2019-04-14 15:14           ` Stefan Monnier
2019-04-14 22:33             ` Phil Sainty
2019-06-27 13:46               ` Performance degradation from long lines Phil Sainty
2019-07-06 14:18                 ` Phil Sainty
2019-07-13  8:07                   ` Eli Zaretskii
2019-07-13  9:07                     ` Stefan Kangas
2019-07-13  9:51                       ` Eli Zaretskii
2019-07-13 10:23                         ` Stefan Kangas
2019-07-13 10:29                           ` Eli Zaretskii
2019-07-13 10:38                             ` Stefan Kangas
2019-07-13 10:58                               ` Phil Sainty
2019-07-13 11:23                                 ` Eli Zaretskii
2019-07-13 11:23                               ` Eli Zaretskii
2019-07-13  9:33                     ` Phil Sainty
2019-07-13  9:56                       ` Eli Zaretskii
2019-07-13 13:31                         ` Stefan Monnier
2019-07-13 13:43                           ` Stefan Kangas
2019-07-13 14:14                           ` Eli Zaretskii
2019-07-13 14:17                             ` Stefan Monnier
2019-07-13 18:17                               ` Eli Zaretskii
2019-07-13 22:22                                 ` Stefan Monnier
2019-07-14  5:39                                   ` Eli Zaretskii
2019-07-15 13:12                                     ` Dmitry Gutov
2019-07-18  6:30                                       ` Eli Zaretskii
2019-07-18 14:48                                         ` Stefan Monnier
2019-07-18 17:11                                           ` Clément Pit-Claudel
2019-07-18 18:11                                             ` Stefan Monnier
2019-07-18 18:33                                           ` Andy Moreton

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=3717982b-8f1b-2e2b-b213-59aeb62bbb93@Alexander.Shukaev.name \
    --to=emacs@alexander.shukaev.name \
    --cc=emacs-devel@gnu.org \
    --cc=mithraeum@protonmail.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).