From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#45412: File ... is large (... MiB), really open? (y)es or (n)o or (l)iterally Date: Sun, 11 Apr 2021 00:32:34 +0200 Message-ID: References: <87k0t72rhd.5.fsf@jidanni.org> <8735zuig9m.fsf@gnus.org> <87wnx62rpe.fsf@mail.linkov.net> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33745"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin) Cc: 45412@debbugs.gnu.org, Lars Ingebrigtsen , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 11 00:34:28 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVMBP-0008fp-W6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 11 Apr 2021 00:34:28 +0200 Original-Received: from localhost ([::1]:47460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVMBP-00027Z-2F for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Apr 2021 18:34:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVMAz-0001yD-UG for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 18:34:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lVMAz-0006W3-LX for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 18:34:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lVMAz-0005Da-JB for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 18:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Apr 2021 22:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45412 X-GNU-PR-Package: emacs Original-Received: via spool by 45412-submit@debbugs.gnu.org id=B45412.161809398319991 (code B ref 45412); Sat, 10 Apr 2021 22:34:01 +0000 Original-Received: (at 45412) by debbugs.gnu.org; 10 Apr 2021 22:33:03 +0000 Original-Received: from localhost ([127.0.0.1]:53520 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lVMA2-0005CN-JB for submit@debbugs.gnu.org; Sat, 10 Apr 2021 18:33:02 -0400 Original-Received: from sonic306-21.consmr.mail.ir2.yahoo.com ([77.238.176.207]:36118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lVM9z-0005Bs-Tv for 45412@debbugs.gnu.org; Sat, 10 Apr 2021 18:33:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1618093973; bh=h8mNo2hhV5oqH2yaduCYaaOoKfS9DrjlXedp0Zi4LGg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=kyP1KHU8k222MPzQO/sAj2ZSjM4M7sOxnCI7vAVagoFeh8DIObk9MmwdHVBduudOdrqH/vyLKdfjETsvIirr2NRRB+9auqTQlOIC6PbhlglnvzzwI0ivbj76vp7D8bdml0FcE6GwCl6QMg7olwkC9lhJ/iX6Retmxr6QTMf4t0ESRuIFP3AYlEP9cOjLms1SnVGCe5VCCy7I9MxDRD8IveQp6qB9Xde2pHa9ujVuUjREyD09PR09UysWZn9pZXVUWwPlIeFrWZKidciG+GwQq8N2CZ2u0aYRx9l7Qp5UGYtl8aeOQlnSjl2K8GhuxmyQRfTFn543um+JHXBGFX7JOw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1618093973; bh=bOzJJl1nk5SX5b6q+7QBKZEx1ezwN99Kip0jOSujriX=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=oPN5o/5BFMZ2M9DLg4zK3X/YeRo65TKtoZ9/biVMsdq02toxI44czpBownAqT0c9+QloUWzeos0xPIZuqk4egz5Q5ws/iexJpm1wJxouseMUgGGbdWgRbDkiIM/zASauO3y0iv37VVyg3uODoWafjGcEkZqg9KAUMhurv8uLavvsoMvtfYcKRPOA7yWWE+hfT7EpL0tagQTm3GbBmb/FCZwIBiWQt6J9TisJdo4YEH4gke8xsb+OvPG8OtBv9Eo1SKI7LybRUA7EdNp+nu0pk77zjW+/8IoAWuyXXd0d+HPm0elZsJfuG/Creca3fXNZ+L0Y04ca0q0S/S3UROOy4w== X-YMail-OSG: ms6yGz4VM1lX0l2.s35X._MS6fGnu.z69nUV4hCfyWwzdmGRG8tPAkFBrrQhhF8 J3Y58SmmbVM1og_iqLJVzZe41cil3bT2Fr.gi81WeJCTRyDnS4K4aAezuClSVXJ4RGxhoCp...17 OjX4jcs8zaB6FN_ImVkRfgTU228kTgxB0.q.YdXBMOKuqfpooedfuYyiNo8y2qcn0QHA7.HDDhfz J_7uyWubDC8_bhI7rvJ2IigZwNrn7m5CTaI.vDDwH4oO1m9nocji_orgAi0Wl6FPfMFPjk8hBxOX bFxpIuAZKu0SS_9Z.xROoVA_2ElkBan0NTd_Nl9nnZwINUrvCDzbBeu14sXrohJAtN.GS_LnpBvS YxKOhsuNJ9Ma3OzvC19RWOL0KGYpWsEUha91N7F4qr3zK056yki9Qb0JVpWS9hlfy7fSzAWgyRt3 WlLzlZfdYXCga7wOU5g5p18YLm2A.WdyjcRKhLDvcynKiCwcdMwHbHUCDQrh7jdNBxkkv0GlS6nb wIyrkxcIROiLzwcUUGFhNZnLitVoq2y8oKlBo4ftwWuhl8Z9NYGd9IquOBLkX87LdmU9m879BG8a yRs7_upHjs6DegIFcLaP02F3rP9A7d3D41hYJ3bz8S6jVEIOyKi6fk2P6D4N9OZls2ojKxa_uNyW qnrB.bpibp9HkWy15RYc_1PjQJ149B1kWU95_mDijCt07XgbbnFPlEenvmiZaHiwfn83yHyTQpob df8TH3DIFS9Avvws8EOia9oAKKlFrGf8XvYT2mDCbWKyhWly0BlIRF0kHyyRPOn3CgnFUmvT0Onx niWWP21rQNOcegULGpKDHox0Zuzt_27Li5hSEVPfJ2 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ir2.yahoo.com with HTTP; Sat, 10 Apr 2021 22:32:53 +0000 Original-Received: by kubenode532.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID e313846aa7081e5b5bfcd248135d174d; Sat, 10 Apr 2021 22:32:48 +0000 (UTC) In-Reply-To: <87wnx62rpe.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 25 Dec 2020 11:32:11 +0200") X-Mailer: WebService/1.1.18121 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/16) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203821 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov writes: >>> Another approach could be to offer a C-h binding that opens a help >>> window that describes the possible options and briefly links to the >>> customization entry point that removes the prompt permanently. >> >> Yeah, that sounds like a good idea. > > I agree, this is really the best idea. OK, I've implemented it in the attached patch. Suggestions welcome. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-a-help-option-in-the-open-large-files-prompt.patch Content-Transfer-Encoding: quoted-printable >From 8ae34d5bca1a8fc13f2388842880d4234ab28165 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Daniel=3D20Mart=3DC3=3DADn?=3D Date: Sun, 11 Apr 2021 00:16:38 +0200 Subject: [PATCH] Add a help option in the open large files prompt * lisp/files.el (files--ask-user-about-large-file-help): New function that displays a Help buffer with information about opening large files in Emacs. (Bug#45412) (files--ask-user-about-large-file): Add a ?/C-h option to the prompt. * etc/NEWS: Advertise the change. --- etc/NEWS | 6 ++++ lisp/files.el | 76 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index a0f05d8cf1..b1bd9689e2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -261,6 +261,12 @@ commands. The new keystrokes are 'C-x x g' ('revert-b= uffer'), ** Commands 'set-frame-width' and 'set-frame-height' can now get their input using the minibuffer. =20 +--- +** When Emacs prompts before opening a large file, a new help window +has been added. This help window describes the available options and +how to disable the prompt by customizing the +'large-file-warning-threshold' variable. + * Editing Changes in Emacs 28.1 =20 diff --git a/lisp/files.el b/lisp/files.el index 60d6034011..49224e4b1e 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2123,28 +2123,62 @@ out-of-memory-warning-percentage =20 (declare-function x-popup-dialog "menu.c" (position contents &optional hea= der)) =20 +(defun files--ask-user-about-large-file-help (op-type size) + "Show a buffer explaining the options to open large files in Emacs." + (with-output-to-temp-buffer "*Help*" + (with-current-buffer standard-output + (insert + (format + "The file that you want to %s is large (%s). + +Large files may be slow to edit or navigate so Emacs asks you +before you try to open such files. + +You can press =E2=80=98y=E2=80=98 to open the file. +You can press =E2=80=98n=E2=80=98 to abort. +You can press =E2=80=98l=E2=80=98 to open the file literally, which means = that +Emacs will open the file without doing any format or character code +conversion and in Fundamental mode, without loading any potentially +expensive feature. + +You can customize the option =E2=80=98large-file-warning-threshold=E2=80= =98 to be +the file size, in bytes, from which Emacs will ask for +confirmation. Set it to =E2=80=98nil=E2=80=98 to never request +confirmation." + op-type + size)) + (save-excursion + (re-search-backward "\\(customize\\)" nil t) + (help-xref-button 1 'help-customize-variable 'large-file-warning-threshol= d))))) + (defun files--ask-user-about-large-file (size op-type filename offer-raw) - (let ((prompt (format "File %s is large (%s), really %s?" - (file-name-nondirectory filename) - (funcall byte-count-to-string-function size) op-type))) - (if (not offer-raw) - (if (y-or-n-p prompt) nil 'abort) - (let* ((use-dialog (and (display-popup-menus-p) - last-input-event - (listp last-nonmenu-event) - use-dialog-box)) - (choice - (if use-dialog - (x-popup-dialog t `(,prompt - ("Yes" . ?y) - ("No" . ?n) - ("Open literally" . ?l))) - (read-char-choice - (concat prompt " (y)es or (n)o or (l)iterally ") - '(?y ?Y ?n ?N ?l ?L))))) - (cond ((memq choice '(?y ?Y)) nil) - ((memq choice '(?l ?L)) 'raw) - (t 'abort)))))) + (save-window-excursion + (let ((prompt (format "File %s is large (%s), really %s?" + (file-name-nondirectory filename) + (funcall byte-count-to-string-function size) op-type))) + (if (not offer-raw) + (if (y-or-n-p prompt) nil 'abort) + (let* ((use-dialog (and (display-popup-menus-p) + last-input-event + (listp last-nonmenu-event) + use-dialog-box)) + choice) + (if use-dialog + (setq choice (x-popup-dialog t `(,prompt + ("Yes" . ?y) + ("No" . ?n) + ("Open literally" . ?l)))) + (while (null choice) + (setq choice (read-char-choice + (concat prompt " (y)es, (n)o, (l)iterally, (?)= ") + '(?y ?Y ?n ?N ?l ?L ?? ?\C-h))) + (when (memq choice '(?? ?\C-h)) + (files--ask-user-about-large-file-help + op-type (funcall byte-count-to-string-function size)) + (setq choice nil)))) + (cond ((memq choice '(?y ?Y)) nil) + ((memq choice '(?l ?L)) 'raw) + (t 'abort))))))) =20 (defun abort-if-file-too-large (size op-type filename &optional offer-raw) "If file SIZE larger than `large-file-warning-threshold', allow user to = abort. --=20 2.31.0 --=-=-=--