From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alexander Shukaev Newsgroups: gmane.emacs.devel Subject: Re: Performance degradation from long lines Date: Fri, 26 Oct 2018 17:34:02 +0200 Message-ID: <3717982b-8f1b-2e2b-b213-59aeb62bbb93@Alexander.Shukaev.name> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1540569511 17143 195.159.176.226 (26 Oct 2018 15:58:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 26 Oct 2018 15:58:31 +0000 (UTC) Cc: mithraeum To: "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 26 17:58:27 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gG4VG-0004Ng-OT for ged-emacs-devel@m.gmane.org; Fri, 26 Oct 2018 17:58:26 +0200 Original-Received: from localhost ([::1]:60818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG4XN-0002HQ-47 for ged-emacs-devel@m.gmane.org; Fri, 26 Oct 2018 12:00:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG4J0-00041t-E8 for emacs-devel@gnu.org; Fri, 26 Oct 2018 11:45:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gG47i-0005qo-5m for emacs-devel@gnu.org; Fri, 26 Oct 2018 11:34:10 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:45467) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gG47h-0005pZ-Sn for emacs-devel@gnu.org; Fri, 26 Oct 2018 11:34:06 -0400 X-Originating-IP: 188.107.67.248 Original-Received: from [192.168.2.109] (dslb-188-107-067-248.188.107.pools.vodafone-ip.de [188.107.67.248]) (Authenticated sender: forum@alexander.shukaev.name) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id E6E82E0016; Fri, 26 Oct 2018 15:34:02 +0000 (UTC) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.70.183.196 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230712 Archived-At: 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