From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 29 12:05:03 2019 Received: (at submit) by debbugs.gnu.org; 29 Dec 2019 17:05:03 +0000 Received: from localhost ([127.0.0.1]:60134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilbzz-0000vU-6K for submit@debbugs.gnu.org; Sun, 29 Dec 2019 12:05:03 -0500 Received: from lists.gnu.org ([209.51.188.17]:39087) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilbzy-0000vL-2W for submit@debbugs.gnu.org; Sun, 29 Dec 2019 12:05:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60350) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilbzw-0000zi-Mc for bug-gnu-emacs@gnu.org; Sun, 29 Dec 2019 12:05:01 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_MED, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ilbzv-0008Eb-7o for bug-gnu-emacs@gnu.org; Sun, 29 Dec 2019 12:05:00 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:38686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ilbzv-0008CH-0D for bug-gnu-emacs@gnu.org; Sun, 29 Dec 2019 12:04:59 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBTH4Sck093241 for ; Sun, 29 Dec 2019 17:04:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=7/MH4heCOqot2hTW1jXmyuOYLvc5k1xlQ/tWw19rOug=; b=YLfnVhvXz3yVZxNSbyICGXrrJKe4dv7vQtz3cmR21uIPkfAZcBby3KNVokv7vxVr8esf g1yBOB2wjQrUTckhX0glAXBf9TscmK2n2bzzpLfK09arpsi5NeYYHw5LVq2pNZAe5H3T oVq1GGFvWmY0585pms3bZZXLWrb4epb7ikyRBs2n8w0S6gMKaDn987z0BEsPVGnn6uHz ot6ap86silgRfOtBcQWUKOJYwgrn9wPcGZVYukh+sIFd0kHsrmeE+HC6oaIPhYwTtgmT C4M5CXtFqUDPPX4WnySFuMFHTkYAUbNIiC98SXqIqkfLqu98BFP+RKY5Ak/Hf5CF0eeu lw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2x5y0pb98h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 29 Dec 2019 17:04:57 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBTH3cdj077528 for ; Sun, 29 Dec 2019 17:04:57 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2x6h6ujp5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 29 Dec 2019 17:04:57 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xBTH4tre032020 for ; Sun, 29 Dec 2019 17:04:56 GMT MIME-Version: 1.0 Message-ID: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> Date: Sun, 29 Dec 2019 09:04:54 -0800 (PST) From: Drew Adams To: bug-gnu-emacs@gnu.org Subject: 26.3; `view-lossage': Use a variable for the lossage limit X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4939.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9485 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912290161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9485 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912290161 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This report is a follow-up to this emacs-devel thread: https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00678.html and to the older thread that it references: https://lists.gnu.org/archive/html/emacs-devel/2006-03/msg01012.html Please use a variable for the limit of how many characters to use for recording lossage. Doing that will give users (and Lisp code) control over the limit. Having a limit that is hard-coded in C is not user-friendly - it's even unemacsy. The latter thread mentioned above ended with RMS's decision to have this taken care of after the release that was then incipient. But this was never done. I'd prefer to see this as a user option, but an ordinary defvar would already be a great improvement. I don't think it's uncommon to have mistakenly typed some keys, gotten in a strange or unfamiliar situation as a result of that, and then tried to find out just what keys led to that. Depending on what else you did in the meantime, before hitting `C-h l' (e.g., to get out of the strange situation), `view-lossage' might not reach far enough backward to show you the mistake you made. It shouldn't be a big deal to move this limit to a Lisp variable. Can this please be done now? --- Not part of this bug report, but `view-lossage' could also be improved by letting you (or Lisp code) filter the recorded "keystroke" history, to remove stuff that you feel is really extraneous (e.g. not keyboard keystrokes). Such filtering could be just hiding that from view. (This is all the more relevant if we can control the lossage limit. The really relevant user input is sometimes a relatively small subset of the full list of recorded events you see now with `C-h l'.) In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-08-29 Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd Windowing system distributor `Microsoft Corp.', version 10.0.17763 Configured using: `configure --without-dbus --host=3Dx86_64-w64-mingw32 --without-compress-install 'CFLAGS=3D-O2 -static -g3'' From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 29 12:30:46 2019 Received: (at 38796) by debbugs.gnu.org; 29 Dec 2019 17:30:46 +0000 Received: from localhost ([127.0.0.1]:60174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilcOs-0002Bg-AE for submit@debbugs.gnu.org; Sun, 29 Dec 2019 12:30:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32889) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilcOq-00025j-9B; Sun, 29 Dec 2019 12:30:44 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50916) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ilcOk-0007d3-Js; Sun, 29 Dec 2019 12:30:39 -0500 Received: from [176.228.60.248] (port=3875 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ilcOJ-0001pt-Pg; Sun, 29 Dec 2019 12:30:34 -0500 Date: Sun, 29 Dec 2019 19:30:15 +0200 Message-Id: <83zhfbm448.fsf@gnu.org> From: Eli Zaretskii To: Drew Adams In-reply-to: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> (message from Drew Adams on Sun, 29 Dec 2019 09:04:54 -0800 (PST)) Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: 38796@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) severity 38796 wishlist thanks > Date: Sun, 29 Dec 2019 09:04:54 -0800 (PST) > From: Drew Adams > > This report is a follow-up to this emacs-devel thread: > > https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00678.html > > and to the older thread that it references: > > https://lists.gnu.org/archive/html/emacs-devel/2006-03/msg01012.html > > Please use a variable for the limit of how many characters to use for > recording lossage. > > Doing that will give users (and Lisp code) control over the limit. > Having a limit that is hard-coded in C is not user-friendly - it's even > unemacsy. It's a constant size of a vector that records the keys in a cyclical fashion. So it isn't enough to expose the value to Lisp; one must also write code that reallocates the vector when the value changes, and copies the keystrokes from the old to the new vector in the correct order. Not rocket science, but still. Patches are welcome. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 29 12:34:29 2019 Received: (at 38796) by debbugs.gnu.org; 29 Dec 2019 17:34:29 +0000 Received: from localhost ([127.0.0.1]:60182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilcSS-0003az-VS for submit@debbugs.gnu.org; Sun, 29 Dec 2019 12:34:29 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:50496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilcSQ-0003al-BE for 38796@debbugs.gnu.org; Sun, 29 Dec 2019 12:34:27 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBTHOvcj104553; Sun, 29 Dec 2019 17:34:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=tZ/q5iSGcJPTIDWAoS4di+VZydMiRv7/BamJi/kF87o=; b=ZpZVd4BQv5d197KxLx3EXgkxlh5eMw2uXj/8AA8VDLjRgojvgNy2pPSz1JAk6CloLpEO V/kOQ50e/nIMVCZjdkHXIePDl/MgTPdWNX2zkJtZdsg5u0SqKL6Lv0c1+TT88A9IEwkv OlM2Wsl5N9an+2TfliuRAmE+1z7dfmmlKbPJJ2YV+d8NlTM/fzwq2UiUqjopF4jROBBh V1G/rJ+CmasXmubFNTnvEuslGAwHELZMtpW25cAbqZepaaRPqxIXgHg6Uw+UYDVY5Vfb u56/dAM0EsSNRlGyD+k+A8/X1G+kvSoQ5pF8q5AZ+KFwhEnswlXl5dg1+t3N0stjk5ua cA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2x5ypqb81j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Dec 2019 17:34:20 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBTHYGCr132374; Sun, 29 Dec 2019 17:34:19 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2x6gjwt7f7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Dec 2019 17:34:19 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xBTHYHvS002641; Sun, 29 Dec 2019 17:34:18 GMT MIME-Version: 1.0 Message-ID: Date: Sun, 29 Dec 2019 09:34:17 -0800 (PST) From: Drew Adams To: Eli Zaretskii Subject: RE: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> In-Reply-To: <83zhfbm448.fsf@gnu.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4939.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9485 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=701 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912290166 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9485 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=780 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912290165 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: 38796@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > It's a constant size of a vector that records the keys in a cyclical > fashion. So it isn't enough to expose the value to Lisp; one must > also write code that reallocates the vector when the value changes, > and copies the keystrokes from the old to the new vector in the > correct order. Not rocket science, but still. I see. I hope such an enhancement is made. > Patches are welcome. A C patch will have to come from someone other than me. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 26 17:58:16 2020 Received: (at 38796) by debbugs.gnu.org; 26 Jun 2020 21:58:16 +0000 Received: from localhost ([127.0.0.1]:43234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jowMR-0007lR-0f for submit@debbugs.gnu.org; Fri, 26 Jun 2020 17:58:15 -0400 Received: from mail-ej1-f41.google.com ([209.85.218.41]:43038) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jowMP-0007lE-Kb for 38796@debbugs.gnu.org; Fri, 26 Jun 2020 17:58:14 -0400 Received: by mail-ej1-f41.google.com with SMTP id l12so10706217ejn.10 for <38796@debbugs.gnu.org>; Fri, 26 Jun 2020 14:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=lnSDDte8TAdofmgOSb0amLGOheXspqblayRmnEdTrAM=; b=jGkp5VylQttutz/+nkhNjbcUaY9BV7Y3wIKjpUsFIEXgEI4CMd7/8KlSh1823sKf4O L4HEDRrcCQTqU93xC8NldhNwqkzrxtvYhhnt4m+BPAWZWhRoJKT4E0S+PHAqb/A4F3c3 G34TDX00CQXO7boreJuUiDKSJq644bHymZ41SODwz2jM9EJBANyUCtT1kTXHVWoa8usE cF4gAUMK1t0dUaRjIcMCG/NVLEfXRHk83JTO9qgRCQpoHltEXp/u5lxjqqq6/y4mUQGQ g2AtmLws0eZPSDYcsUwd5i7Fs6yl9S4+u7aavIvlpc50limD3GxPNnMMeb2UI5yjs/XC 9a3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=lnSDDte8TAdofmgOSb0amLGOheXspqblayRmnEdTrAM=; b=XgUyPb2YQn5RrwsSAIpI1gW0ae+MqALLw3f18hM9HRSow/Zv2a+wMRN0ucBvoMRq4r hi3KaBN8uWx5ETYNdWG/QmLbi9sUoz6haK5FspyLKqzhVyKpmEgyCR2bmJMYDZyqFG6x nyazsZjyC6RhqnV9TaxH6n4PE3KRSHUbW93o6Ct/vzoEV9Pqe4FQbCB/ODrn03tciwW5 bSMzgzp+vrjmb7KA0n/V7SxZiGTSaABdz5XHlRCe/hDjgCN3CuIuU6S2E2yaYx0GZYQv 4Akkp+Hul9sY4O+nRIWFz1oNsZhHP74AdX4YcW1YyFG3i2OfxNekYWw4k0qllLVo7SOX /QQA== X-Gm-Message-State: AOAM533BQrPfB2E24GzwBQogAtRV1/6JzK092h5e+HcBWYNe1vo2gzIg txjI3nKVm954z8W3g93zYMs= X-Google-Smtp-Source: ABdhPJz2Yj2tsqFFRqql7nyv1tnZa+mUzJxvzUAbHUXH1V4sKOApMx+JUtSJxESBS+pY44O2r14fSQ== X-Received: by 2002:a17:906:6713:: with SMTP id a19mr4580416ejp.11.1593208687245; Fri, 26 Jun 2020 14:58:07 -0700 (PDT) Received: from calancha-pc.dy.bbexcite.jp ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id 23sm7868404edx.75.2020.06.26.14.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 14:58:06 -0700 (PDT) From: Tino Calancha To: 38796@debbugs.gnu.org Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> Date: Fri, 26 Jun 2020 23:58:01 +0200 In-Reply-To: <83zhfbm448.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 29 Dec 2019 19:30:15 +0200") Message-ID: <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: Eli Zaretskii , tino.calancha@gmail.com, Stefan Monnier , 38796@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Drew Adams >> This report is a follow-up to this emacs-devel thread: >> https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00678.html >> and to the older thread that it references: >> https://lists.gnu.org/archive/html/emacs-devel/2006-03/msg01012.html >> Please use a variable for the limit of how many characters to use for >> recording lossage. > it isn't enough to expose the value to Lisp; one must > also write code that reallocates the vector when the value changes, > and copies the keystrokes from the old to the new vector in the > correct order. > > Patches are welcome. I have uploaded the branch feature/bug#38796-lossage-limit [I've been using it during last 10 days with no issues] Initially I decided to hardcode a sensible minimum of 100 (keeping the current default of 300). That is the first commit. Actually, the code works for N > 0, but as Drew suggested, a value < 100 (which gives only ~ 50 lines of past inputs) is too small to be useful for the use case of checking typing mistakes. After some time I thought that, for some people (anyone in this thread), a very small value in fact can be seen as a security feature; see for instance the docstrings of `term-read-noecho' and `comint-send-invisible'. That motivates the second commit. --8<-----------------------------cut here---------------start------------->8--- commit 9723c2645c8f47e651a81a023e80f882d181cc3f Author: Tino Calancha Date: Sun Jun 7 23:37:59 2020 +0200 Give Lisp control on the lossage size Add an user option to control the maximum number of recorded keystrokes (a.k.a lossage limit) (Bug#38796). * src/keyboard.c (lossage-limit): Add new variable. (MIN_NUM_RECENT_KEYS): Renamed from NUM_RECENT_KEYS. Set it as 100 and use it as the minimum value for lossage-limit. Keep the same default for the vector size as before (300). (update-lossage-limit): New function. (update_recent_keys): Helper function. (command_loop_1) (record_char) (recent-keys) (syms_of_keyboard): Replace NUM_RECENT_KEYS with lossage_limit as the vector size. (clear-this-command-keys): Fix docstring. * lisp/help.el (view-lossage): Mention lossage-limit in the docstring. * lisp/cus-start.el (lossage-limit): Register it as an user option. * lisp/edmacro.el (edit-kbd-macro): Update docstring and commentary header. * etc/NEWS (Changes in Emacs 28.1): Announce the new option. * doc/emacs/help.texi (Misc Help): Document it. * test/src/keyboard-tests.el (keyboard-lossage-limit): Add test. diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index 167c32c4d2..e2c0dc6802 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -563,10 +563,13 @@ Misc Help @kindex C-h l @findex view-lossage +@vindex lossage-limit If something surprising happens, and you are not sure what you typed, use @kbd{C-h l} (@code{view-lossage}). @kbd{C-h l} displays your last -300 input keystrokes and the commands they invoked. If you see -commands that you are not familiar with, you can use @kbd{C-h k} or +input keystrokes and the commands they invoked. By default, Emacs +stores the last 300 events; if you wish, you can change this number +with the option @code{lossage-limit}. +If you see commands that you are not familiar with, you can use @kbd{C-h k} or @kbd{C-h f} to find out what they do. @kindex C-h e diff --git a/etc/NEWS b/etc/NEWS index d58a61be21..da204c5825 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -70,6 +70,10 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". * Changes in Emacs 28.1 ++++ +** The new option 'lossage-limit' controls the maximum number +of keystrokes and commands recorded. + ** Support for '(box . SIZE)' 'cursor-type'. By default, 'box' cursor always has a filled box shape. But if you specify 'cursor-type' to be '(box . SIZE)', the cursor becomes a hollow diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 6632687da4..1ebf554b2b 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -352,6 +352,8 @@ minibuffer-prompt-properties--setter ;; indent.c (indent-tabs-mode indent boolean) ;; keyboard.c + (lossage-limit keyboard integer "28.1" + :set (lambda (_ val) (update-lossage-limit val))) (meta-prefix-char keyboard character) (auto-save-interval auto-save integer) (auto-save-no-message auto-save boolean "27.1") diff --git a/lisp/edmacro.el b/lisp/edmacro.el index 71474c0289..089fea17ef 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -35,8 +35,8 @@ ;; * `M-x' followed by a command name, to edit a named command ;; whose definition is a keyboard macro. ;; -;; * `C-h l' (view-lossage), to edit the 300 most recent keystrokes -;; and install them as the "current" macro. +;; * `C-h l' (view-lossage), to edit the `lossage-limit' most recent +;; keystrokes and install them as the "current" macro. ;; ;; * any key sequence whose definition is a keyboard macro. ;; @@ -88,7 +88,7 @@ edit-kbd-macro "Edit a keyboard macro. At the prompt, type any key sequence which is bound to a keyboard macro. Or, type `\\[kmacro-end-and-call-macro]' or RET to edit the last -keyboard macro, `\\[view-lossage]' to edit the last 300 +keyboard macro, `\\[view-lossage]' to edit the last `lossage-limit' keystrokes as a keyboard macro, or `\\[execute-extended-command]' to edit a macro by its command name. With a prefix argument, format the macro in a more concise way." diff --git a/lisp/help.el b/lisp/help.el index b7d867eb70..9e3d0922d0 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -456,9 +456,10 @@ view-external-packages (info "(efaq)Packages that do not come with Emacs")) (defun view-lossage () - "Display last few input keystrokes and the commands run. + "Display last input keystrokes and the commands run. For convenience this uses the same format as `edit-last-kbd-macro'. +See `lossage-limit' to update the number of recorded keystrokes. To record all your input, use `open-dribble-file'." (interactive) diff --git a/src/keyboard.c b/src/keyboard.c index f9b9399d50..a4d27c94fb 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -103,7 +103,7 @@ static KBOARD *all_kboards; /* True in the single-kboard state, false in the any-kboard state. */ static bool single_kboard; -#define NUM_RECENT_KEYS (300) +#define MIN_NUM_RECENT_KEYS (100) /* Index for storing next element into recent_keys. */ static int recent_keys_index; @@ -111,7 +111,7 @@ static int recent_keys_index; /* Total number of elements stored into recent_keys. */ static int total_keys; -/* This vector holds the last NUM_RECENT_KEYS keystrokes. */ +/* This vector holds the last lossage_limit keystrokes. */ static Lisp_Object recent_keys; /* Vector holding the key sequence that invoked the current command. @@ -294,6 +294,7 @@ static union buffered_input_event *kbd_fetch_ptr; /* Pointer to next place to store character in kbd_buffer. */ static union buffered_input_event *kbd_store_ptr; + /* The above pair of variables forms a "queue empty" flag. When we enqueue a non-hook event, we increment kbd_store_ptr. When we dequeue a non-hook event, we increment kbd_fetch_ptr. We say that @@ -1421,10 +1422,10 @@ command_loop_1 (void) /* Execute the command. */ { - total_keys += total_keys < NUM_RECENT_KEYS; + total_keys += total_keys < lossage_limit; ASET (recent_keys, recent_keys_index, Fcons (Qnil, cmd)); - if (++recent_keys_index >= NUM_RECENT_KEYS) + if (++recent_keys_index >= lossage_limit) recent_keys_index = 0; } Vthis_command = cmd; @@ -3248,15 +3249,15 @@ record_char (Lisp_Object c) int ix1, ix2, ix3; if ((ix1 = recent_keys_index - 1) < 0) - ix1 = NUM_RECENT_KEYS - 1; + ix1 = lossage_limit - 1; ev1 = AREF (recent_keys, ix1); if ((ix2 = ix1 - 1) < 0) - ix2 = NUM_RECENT_KEYS - 1; + ix2 = lossage_limit - 1; ev2 = AREF (recent_keys, ix2); if ((ix3 = ix2 - 1) < 0) - ix3 = NUM_RECENT_KEYS - 1; + ix3 = lossage_limit - 1; ev3 = AREF (recent_keys, ix3); if (EQ (XCAR (c), Qhelp_echo)) @@ -3307,12 +3308,12 @@ record_char (Lisp_Object c) { if (!recorded) { - total_keys += total_keys < NUM_RECENT_KEYS; + total_keys += total_keys < lossage_limit; ASET (recent_keys, recent_keys_index, /* Copy the event, in case it gets modified by side-effect by some remapping function (bug#30955). */ CONSP (c) ? Fcopy_sequence (c) : c); - if (++recent_keys_index >= NUM_RECENT_KEYS) + if (++recent_keys_index >= lossage_limit) recent_keys_index = 0; } else if (recorded < 0) @@ -3326,10 +3327,10 @@ record_char (Lisp_Object c) while (recorded++ < 0 && total_keys > 0) { - if (total_keys < NUM_RECENT_KEYS) + if (total_keys < lossage_limit) total_keys--; if (--recent_keys_index < 0) - recent_keys_index = NUM_RECENT_KEYS - 1; + recent_keys_index = lossage_limit - 1; ASET (recent_keys, recent_keys_index, Qnil); } } @@ -10410,6 +10411,55 @@ If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */) ? Qt : Qnil); } +static void +update_recent_keys (int new_size, int kept_keys) +{ + int osize = ASIZE (recent_keys); + eassert (recent_keys_index < osize); + eassert (kept_keys <= min (osize, new_size)); + Lisp_Object v = make_nil_vector (new_size); + int i, idx; + for (i = 0; i < kept_keys; ++i) + { + idx = recent_keys_index - kept_keys + i; + while (idx < 0) + idx += osize; + ASET (v, i, AREF (recent_keys, idx)); + } + recent_keys = v; + total_keys = kept_keys; + recent_keys_index = total_keys % new_size; + lossage_limit = new_size; + +} + +/* Reallocate recent_keys copying the keystrokes in the right order */ +DEFUN ("update-lossage-limit", Fupdate_lossage_limit, + Supdate_lossage_limit, 1, 1, 0, + doc: /* Update the maximum number of saved keystrokes to ARG. +usage: (update-lossage-limit ARG) */) + (Lisp_Object arg) +{ + if (!FIXNATP (arg)) + user_error ("Value must be a positive integer"); + int osize = ASIZE (recent_keys); + eassert (lossage_limit == osize); + int min_size = MIN_NUM_RECENT_KEYS; + int new_size = XFIXNAT (arg); + + if (new_size == osize) + return Qnil; + if (new_size < min_size) + { + AUTO_STRING (fmt, "Value must be >= %d"); + Fsignal (Quser_error, list1 (CALLN (Fformat, fmt, make_fixnum (min_size)))); + } + int kept_keys = new_size > osize ? total_keys : min (new_size, total_keys); + update_recent_keys (new_size, kept_keys); + + return Qnil; +} + DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, doc: /* Return vector of last few events, not counting those from keyboard macros. If INCLUDE-CMDS is non-nil, include the commands that were run, @@ -10419,21 +10469,21 @@ represented as pseudo-events of the form (nil . COMMAND). */) bool cmds = !NILP (include_cmds); if (!total_keys - || (cmds && total_keys < NUM_RECENT_KEYS)) + || (cmds && total_keys < lossage_limit)) return Fvector (total_keys, XVECTOR (recent_keys)->contents); else { Lisp_Object es = Qnil; - int i = (total_keys < NUM_RECENT_KEYS + int i = (total_keys < lossage_limit ? 0 : recent_keys_index); - eassert (recent_keys_index < NUM_RECENT_KEYS); + eassert (recent_keys_index < lossage_limit); do { Lisp_Object e = AREF (recent_keys, i); if (cmds || !CONSP (e) || !NILP (XCAR (e))) es = Fcons (e, es); - if (++i >= NUM_RECENT_KEYS) + if (++i >= lossage_limit) i = 0; } while (i != recent_keys_index); es = Fnreverse (es); @@ -10531,8 +10581,8 @@ The value is always a vector. */) DEFUN ("clear-this-command-keys", Fclear_this_command_keys, Sclear_this_command_keys, 0, 1, 0, doc: /* Clear out the vector that `this-command-keys' returns. -Also clear the record of the last 100 events, unless optional arg -KEEP-RECORD is non-nil. */) +Also clear the record of the last `lossage-limit' keystroke events, +unless optional arg KEEP-RECORD is non-nil. */) (Lisp_Object keep_record) { int i; @@ -11686,7 +11736,23 @@ syms_of_keyboard (void) staticpro (&modifier_symbols); } - recent_keys = make_nil_vector (NUM_RECENT_KEYS); + DEFVAR_INT ("lossage-limit", lossage_limit, + doc: /* Maximum number of stored keyboard events and commands run. + +Please, do not set this variable in Lisp with `setq' neither +let-bind it, that will likely crash Emacs. This is because +`setq' only changes the variable, but it doesn't update +the size of the internal vector that holds the keystrokes. + +To update this variable use the customization menu, or +call from Lisp the following expression: + + (update-lossage-limit new-limit) + +That takes care of both, the variable and the internal vector.*/); + lossage_limit = 3 * MIN_NUM_RECENT_KEYS; + + recent_keys = make_nil_vector (lossage_limit); staticpro (&recent_keys); this_command_keys = make_nil_vector (40); @@ -11736,6 +11802,7 @@ syms_of_keyboard (void) defsubr (&Srecursive_edit); defsubr (&Sinternal_track_mouse); defsubr (&Sinput_pending_p); + defsubr (&Supdate_lossage_limit); defsubr (&Srecent_keys); defsubr (&Sthis_command_keys); defsubr (&Sthis_command_keys_vector); diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el index 1988ba51a7..017d239246 100644 --- a/test/src/keyboard-tests.el +++ b/test/src/keyboard-tests.el @@ -32,5 +32,16 @@ (read-event nil nil 2)) ?\C-b))) +(ert-deftest keyboard-lossage-limit () + "Test `lossage-limit' updates." + (dolist (val (list 100 100 200 500 300 1000 700)) + (update-lossage-limit val) + (should (= val lossage-limit))) + (let ((current-limit lossage-limit)) + (should-error (update-lossage-limit 5)) + (should-error (update-lossage-limit "200")) + (should (= lossage-limit current-limit)))) + + (provide 'keyboard-tests) ;;; keyboard-tests.el ends here commit a60a05994aff16bc27f153ea8f765e15b92f21be Author: Tino Calancha Date: Mon Jun 22 22:41:34 2020 +0200 Allow disable the record of keystrokes (lossage) Use 1 as the minimum value for lossage-limit; such a value is equivalent to not recording the keystrokes: having just 1 entry, will be overwritten with the view-lossage call itself. * test/src/keyboard-tests.el (keyboard-lossage-limit): Update test. * src/keyboard.c (MIN_NUM_RECENT_KEYS): Delete it. (lossage_limit): Add security note in the doctring. * lisp/cus-start.el (lossage-limit): Let users choose to disable the record of the keystrokes. * doc/emacs/help.texi (Misc Help): Update manual. * etc/NEWS (Changes in Emacs 28.1): Mention that it's possible to disable the record of keystrokes. diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index e2c0dc6802..69ea96763b 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -569,8 +569,14 @@ Misc Help input keystrokes and the commands they invoked. By default, Emacs stores the last 300 events; if you wish, you can change this number with the option @code{lossage-limit}. -If you see commands that you are not familiar with, you can use @kbd{C-h k} or -@kbd{C-h f} to find out what they do. +If you see commands that you are not familiar with, you can use @kbd{C-h k} +or @kbd{C-h f} to find out what they do. +If you don't like that Emacs saves your keystrokes, then you can +set @code{lossage-limit} equal to 1; such a value effectively disables the +record of the keystrokes. Please, do not set this option with @code{setq} +neither let-bind it; that will likely crash Emacs. Use instead the +customization menu, which also updates the internal structure holding +the keystrokes. @kindex C-h e @findex view-echo-area-messages diff --git a/etc/NEWS b/etc/NEWS index da204c5825..17776173e0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -72,7 +72,8 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". +++ ** The new option 'lossage-limit' controls the maximum number -of keystrokes and commands recorded. +of keystrokes and commands recorded. The value 1 disables +the record of keystrokes. ** Support for '(box . SIZE)' 'cursor-type'. By default, 'box' cursor always has a filled box shape. But if you diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 1ebf554b2b..bd4ff3a74b 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -352,7 +352,11 @@ minibuffer-prompt-properties--setter ;; indent.c (indent-tabs-mode indent boolean) ;; keyboard.c - (lossage-limit keyboard integer "28.1" + (lossage-limit keyboard + (choice (const :tag "Do not record keystrokes" 1) + integer) + "28.1" + :standard 300 :set (lambda (_ val) (update-lossage-limit val))) (meta-prefix-char keyboard character) (auto-save-interval auto-save integer) diff --git a/src/keyboard.c b/src/keyboard.c index a4d27c94fb..9af1b9ba50 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -103,8 +103,6 @@ static KBOARD *all_kboards; /* True in the single-kboard state, false in the any-kboard state. */ static bool single_kboard; -#define MIN_NUM_RECENT_KEYS (100) - /* Index for storing next element into recent_keys. */ static int recent_keys_index; @@ -10444,7 +10442,7 @@ usage: (update-lossage-limit ARG) */) user_error ("Value must be a positive integer"); int osize = ASIZE (recent_keys); eassert (lossage_limit == osize); - int min_size = MIN_NUM_RECENT_KEYS; + int min_size = 1; int new_size = XFIXNAT (arg); if (new_size == osize) @@ -11749,8 +11747,11 @@ call from Lisp the following expression: (update-lossage-limit new-limit) -That takes care of both, the variable and the internal vector.*/); - lossage_limit = 3 * MIN_NUM_RECENT_KEYS; +That takes care of both, the variable and the internal vector. + +Security note: The value 1 makes impossible to recover a typed string +with `view-lossage'.*/); + lossage_limit = 300; recent_keys = make_nil_vector (lossage_limit); staticpro (&recent_keys); diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el index 017d239246..4541c389d0 100644 --- a/test/src/keyboard-tests.el +++ b/test/src/keyboard-tests.el @@ -38,7 +38,7 @@ (update-lossage-limit val) (should (= val lossage-limit))) (let ((current-limit lossage-limit)) - (should-error (update-lossage-limit 5)) + (should-error (update-lossage-limit 0)) (should-error (update-lossage-limit "200")) (should (= lossage-limit current-limit)))) --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 28.0.50 (build 18, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0) of 2020-06-26 built on calancha-pc.dy.bbexcite.jp Repository revision: ffb89ed5f07491e33fc79d8b4be49d9deba2ad4a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 27 04:33:23 2020 Received: (at 38796) by debbugs.gnu.org; 27 Jun 2020 08:33:23 +0000 Received: from localhost ([127.0.0.1]:43452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jp6H5-0007iO-9b for submit@debbugs.gnu.org; Sat, 27 Jun 2020 04:33:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jp6H1-0007iB-VL for 38796@debbugs.gnu.org; Sat, 27 Jun 2020 04:33:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54653) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jp6Gw-0008S0-AW; Sat, 27 Jun 2020 04:33:14 -0400 Received: from [176.228.60.248] (port=2841 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jp6Gv-0002oM-Lp; Sat, 27 Jun 2020 04:33:14 -0400 Date: Sat, 27 Jun 2020 11:32:57 +0300 Message-Id: <83v9jc3o3q.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-Reply-To: <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> (message from Tino Calancha on Fri, 26 Jun 2020 23:58:01 +0200) Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: monnier@iro.umontreal.ca, 38796@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Tino Calancha > Cc: 38796@debbugs.gnu.org, Eli Zaretskii , Stefan Monnier > ,uyennhi.qm@gmail.com, tino.calancha@gmail.com > Date: Fri, 26 Jun 2020 23:58:01 +0200 > > Eli Zaretskii writes: > > >> From: Drew Adams > >> This report is a follow-up to this emacs-devel thread: > >> https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00678.html > >> and to the older thread that it references: > >> https://lists.gnu.org/archive/html/emacs-devel/2006-03/msg01012.html > >> Please use a variable for the limit of how many characters to use for > >> recording lossage. > > > it isn't enough to expose the value to Lisp; one must > > also write code that reallocates the vector when the value changes, > > and copies the keystrokes from the old to the new vector in the > > correct order. > > > > Patches are welcome. > > I have uploaded the branch feature/bug#38796-lossage-limit > [I've been using it during last 10 days with no issues] > > Initially I decided to hardcode a sensible minimum of 100 (keeping > the current default of 300). That is the first commit. > Actually, the code works for N > 0, but as Drew suggested, a value < 100 > (which gives only ~ 50 lines of past inputs) is too small to be useful > for the use case of checking typing mistakes. > > After some time I thought that, for some people (anyone in this thread), > a very small value in fact can be seen as a security feature; > see for instance the docstrings of `term-read-noecho' and > `comint-send-invisible'. That motivates the second commit. Thanks. Some initial comments below: . The original request was for allowing to keep _more_ than just 300 keystrokes, there was no request for recording less than that number. I'm not sure we should allow reducing the number; if someone thinks it could be a security issue, then we should have a separate feature that disabled recording the keys, not as a side effect of reducing the vector size. . The size of the vector shouldn't be exposed to Lisp, there's no reason for doing that. You say in the doc string of the variable not to set nor bind it, but documenting the restriction is not enough, as someone, perhaps even some malicious code, could just do what you ask not to. Instead, there should be a function to get the value and a function to set the value (which should also resize the vector as a side effect). . Using 1 as the value that disables recording is unnatural; it might be convenient from the implementation POV, but this implementation convenience cannot justify asking the users to remember such a strange convention. The usual way of disabling a feature is either by setting the value to zero or using a suitable symbol, like nil. (But I'm not sure we should provide this feature as part of this changeset, see below.) . Last, but not least: if we are going to allow to disable recording of keys, we should carefully audit all the places that call recent-keys, and make sure they will not break due to such a radical change. My personal view is that we should allow only growing the size and resetting it to the original size of 300. Disabling the key record should be a separate feature, most probably implemented by means other than shrinking the recent_keys vector. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 28 12:55:19 2020 Received: (at 38796) by debbugs.gnu.org; 28 Jun 2020 16:55:19 +0000 Received: from localhost ([127.0.0.1]:46846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpaaN-000856-Iy for submit@debbugs.gnu.org; Sun, 28 Jun 2020 12:55:19 -0400 Received: from mail-ej1-f41.google.com ([209.85.218.41]:44287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpaaL-00084o-LW for 38796@debbugs.gnu.org; Sun, 28 Jun 2020 12:55:18 -0400 Received: by mail-ej1-f41.google.com with SMTP id ga4so14226313ejb.11 for <38796@debbugs.gnu.org>; Sun, 28 Jun 2020 09:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=k4x0dj/mL1S42HZK9g63APinIVPw2FPSIQlxBc7ip7s=; b=OuGu+s2ccGjnYmCbWkXVbR08gagjkwobfHSFB9m73c9HyjrF0vAxVuqeHJfswGzmF1 4QF4Y9v0XKXYUcIyijMg5pZHjPN5N2SKJ78dvFDYYDpON/JyD/oqHF0ArdNRzhMZCjgS 71C9LfJdGvsjSrKfpjgQHpoainEZc8s82J49YiBSgAHCY5SK7+1HSWpBT3P6Xysl5SUe Q9SiWanse09tzI31Iew418w68xDN8FwRs3DhuRpfEXDGEfn9tLNoshspTaizBUU26Ait MDATyeWoHKtn6EPoc3rHVfBPDJdxDr6QxwSKGNWkCqfgjh6/AZKovniNRBBDF2XewFmq hm0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=k4x0dj/mL1S42HZK9g63APinIVPw2FPSIQlxBc7ip7s=; b=iHa90a9oxQ72RltgLmZQ9yZTFgMqHH6XPoYaOnTgAvJg+84Nuq/cnh3mk4HVZWEAJ4 knvuLcfVQ6FC0oLUiMvjfgICocGLqCUAbSCpH9hD2r+ptSw/BhI9PFiRMjFYSAxeaLHJ e49ianr8CgXLE6uxUyVuP0wWD+ej3Wsr1+gVZ9Uxu1guXay71WxUiowAaFK9sPtTWDfZ 4wlcIDBc55dsRcNMTBjzGsFL76CkbOcFhbbE5eS7eqP3wqgj+RK5Feyx0ZjemXCCnHXV 04s5I1opNlgBF9MSMX0Cx0d5z325EO/sRSiIfSF/sE3NRQ7/FVIcBQQfq3LJcyD7YTa7 y+/A== X-Gm-Message-State: AOAM532py9gjlRI1Y2E6+18W3YzJ706jwODhp9FK3Q9m6ht0tdNhWu5I wu1ZeoWPKZcMaS5BhU4SX7I= X-Google-Smtp-Source: ABdhPJxiEP3dMf0zEPpYAXBYTsdiFXYQjG5EQNacjuv5yMbmYmg+FcG+SSAT0vOMsKR16sR0u0AO5g== X-Received: by 2002:a17:906:6453:: with SMTP id l19mr10432519ejn.262.1593363311743; Sun, 28 Jun 2020 09:55:11 -0700 (PDT) Received: from calancha-pc.dy.bbexcite.jp ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id k23sm22848831ejo.120.2020.06.28.09.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jun 2020 09:55:11 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Sun, 28 Jun 2020 18:55:09 +0200 (CEST) X-X-Sender: calancha@calancha-pc.dy.bbexcite.jp To: Eli Zaretskii Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit In-Reply-To: <83v9jc3o3q.fsf@gnu.org> Message-ID: References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: uyennhi.qm@gmail.com, monnier@iro.umontreal.ca, 38796@debbugs.gnu.org, Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sat, 27 Jun 2020, Eli Zaretskii wrote: > My personal view is that we should allow only growing the size and > resetting it to the original size of 300. Disabling the key record > should be a separate feature, most probably implemented by means other > than shrinking the recent_keys vector. I totally agree: they are clearly 2 separated features. Thanks for the comments, I will work on them and get back once completed and tested. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 28 14:01:00 2020 Received: (at 38796) by debbugs.gnu.org; 28 Jun 2020 18:01:00 +0000 Received: from localhost ([127.0.0.1]:46886 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpbbw-0001L7-IZ for submit@debbugs.gnu.org; Sun, 28 Jun 2020 14:01:00 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:14358) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpbbu-0001Ku-Bp for 38796@debbugs.gnu.org; Sun, 28 Jun 2020 14:00:59 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0156544093A; Sun, 28 Jun 2020 14:00:52 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 8D7694402C1; Sun, 28 Jun 2020 14:00:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1593367247; bh=xnDWYoqNtyG8vmAUE+WRfH7I1pVYpYZ379qog+YRXX0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=SilFY2zV1OMk8wQlU5TcABOZh+WmzIidDUe71hMMBSTB8coNNZVGILpQHFrYzac00 4AAP/MY5ymFNU83e8EUsQ25l07CgewS1RgJR47rfGQMcH4FFmwfub1D3XOVJMFLk6k TDdznVAsAOpg03vmWYVifA9HdSd4IGMZjSVnkLz2QNcUIPfCQ6F3Afc9xcx2OnvFs5 o0pjRTj3E50UrCMAeOybCT4d7+jsoyfNiSeqKjLM1WAQ0sGaX16x/w0ZoxJIDDwVP7 tVoAUEn9p2Uc1mQMQI+q5/A+cQVRYOFzAaR+4ICzwpEUMpS8yXSiH6OFdIKWVJN8a9 cNOPKvD1eoRBw== Received: from ceviche (xplr-96-63-48-187.xplornet.com [96.63.48.187]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A0E471209C3; Sun, 28 Jun 2020 14:00:40 -0400 (EDT) From: Stefan Monnier To: Tino Calancha Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit Message-ID: References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> Date: Sun, 28 Jun 2020 14:00:33 -0400 In-Reply-To: (Tino Calancha's message of "Sun, 28 Jun 2020 18:55:09 +0200 (CEST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.250 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: Eli Zaretskii , uyennhi.qm@gmail.com, 38796@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> My personal view is that we should allow only growing the size and >> resetting it to the original size of 300. Disabling the key record >> should be a separate feature, most probably implemented by means other >> than shrinking the recent_keys vector. > > I totally agree: they are clearly 2 separated features. > > Thanks for the comments, I will work on them and get back once > completed and tested. I agree that disabling should not necessarily be implemented by "abusing" the max-lossage setting. But I don't see any reason to impose a 300 minimum either. I think it's fine to impose a minimum, but it should be dictated by the limits of the code. I'm not saying we should work to push this lower limit down, but just that it should reflect what the code can do safely rather than being an arbitrary number like 300 (I'm pretty sure 100 would be safe as well, since that's what we've used for many years). Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 28 16:01:20 2020 Received: (at 38796) by debbugs.gnu.org; 28 Jun 2020 20:01:20 +0000 Received: from localhost ([127.0.0.1]:46987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpdUO-0004bU-4F for submit@debbugs.gnu.org; Sun, 28 Jun 2020 16:01:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpdUK-0004b7-Qs for 38796@debbugs.gnu.org; Sun, 28 Jun 2020 16:01:18 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05SJx8oa067086; Sun, 28 Jun 2020 20:01:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=mMMXh2QxPIRWX07KtQ/Oqje31WenqGHQkq8pQtMVdc4=; b=MFV3yMa9zLSm/K24poR00mBupI93Nt2zPa28cCAtpaQGvpkFCVwdHow7F9CqIYC2XJrl 6AD08yWDix+J3nLXB9z/XUYPiPwF9o6w7SvmQ0YjTSpWZvPps3K2L6GwslT/iQjnRkDA O9VlZ3HTu/b9rLi/uvdFn6sCX5TykhyfDwZdZpEdE44y7kKvuIfYOgF+zgSLQBwusyWd WXYtaS7FSkkg+Iqafzs4xEuRbF3hlMjBkvmldR1MSr6GPRnQkLCfS2O5b8yx4gaRSr2Z a9YfmUAKww4lxVdXm4hdcl2QaIy4TlGiqo23HjCEwsmb69iZBRKjqrM3GD3QVN5hyZ4x sw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 31wxrmue38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 28 Jun 2020 20:01:11 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05SJwKA3026756; Sun, 28 Jun 2020 20:01:10 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 31xfpjx9jd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 28 Jun 2020 20:01:10 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05SK18ih015906; Sun, 28 Jun 2020 20:01:08 GMT MIME-Version: 1.0 Message-ID: Date: Sun, 28 Jun 2020 20:01:07 +0000 (UTC) From: Drew Adams To: Stefan Monnier , Tino Calancha Subject: RE: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5017.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9666 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006280149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9666 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 bulkscore=0 clxscore=1011 malwarescore=0 phishscore=0 adultscore=0 cotscore=-2147483648 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006280149 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: uyennhi.qm@gmail.com, 38796@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I agree that disabling should not necessarily be implemented by > "abusing" the max-lossage setting. >=20 > But I don't see any reason to impose a 300 minimum either. I think it's > fine to impose a minimum, but it should be dictated by the limits of the > code. I'm not saying we should work to push this lower limit down, but > just that it should reflect what the code can do safely rather than > being an arbitrary number like 300 (I'm pretty sure 100 would be safe as > well, since that's what we've used for many years). OP here. ++++ +** The new option 'lossage-limit' controls the +maximum number of keystrokes and commands recorded. I don't feel strongly about what's done wrt low values or turning such logging off. As Eli said, the point of the enhancement request is to let users control the max, in particular to be able to make it _larger_ than the default (300). I think I understand why some have argued for a second option for turning logging off. But I don't think it's a great argument (IIUC). I agree with Stefan that disabling should not _necessarily_ be carried out by setting the max limit (e.g. to 0). Not _necessary_, but isn't that logical, from a user point of view? I wouldn't call that "abusing" the max-limit option. 1. In general in Emacs, setting a maximum of zero does (and should) do just what it says: not allow ANY . 2. Having 2 options here goes against Occam, and is likely to lead to some confusion (perhaps even some mistakes, in terms of security?). It'll require the doc of each option to mention the other, in hopes that users will consult both. Iffy if really you see a security problem here. It'll mean that the defcustom for the max one needs to prevent a value as low as zero, in order to avoid misunderstanding. E.g., what would it even mean for a history of length zero that does not, in effect, disable logging? Is the real reason for not letting zero turn off logging a C-implementation reason? What's really wrong, from a user point of view, with doing that? Again, this isn't super important. The request was for users to be able to customize the length, in particular to be able to _increase_ it. But if we allow such length customization, why complicate things by adding another option for getting the natural effect of length zero, i.e., turning logging off? I'm more often in the position of arguing for more, not fewer, options, even when they combine to control something. But this time (until I understand better perhaps), that's not the case. ___ Another possibility is to have, for the same option, a specific value other than zero, to indicate disabling. E.g. `disable' or some other non-number value. But then you have the same confusion, if the numeric value can itself be 0. ___ Although it's not part of this enhancement request, as was mentioned from the outset the main problem with `view-lossage' output (of any length) is the low signal-to-noise ratio. It would really be good to be able to (on the fly) filter out certain kinds of input, in particular kinds of non-keyboard input. Besides on-the-fly filtering, it might be good to have a user variable, to define a preference for (default) filtering. Another nice-to-have would be a way (e.g. filter) to not show the commands long with their keys. For someone who knows the commands associated with keys, they are pretty much noise. And we could perhaps put links on the keys to their commands in the current keymap context. Increasing the logging length is only one possible improvement. In general, we should be looking for ways to help users see what they think is important in a log - ways to show/hide different things. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 28 17:53:16 2020 Received: (at 38796) by debbugs.gnu.org; 28 Jun 2020 21:53:16 +0000 Received: from localhost ([127.0.0.1]:47119 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpfEh-0003Th-Et for submit@debbugs.gnu.org; Sun, 28 Jun 2020 17:53:16 -0400 Received: from mail-ej1-f68.google.com ([209.85.218.68]:45103) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpfEe-0003TO-8P for 38796@debbugs.gnu.org; Sun, 28 Jun 2020 17:53:14 -0400 Received: by mail-ej1-f68.google.com with SMTP id a1so14640422ejg.12 for <38796@debbugs.gnu.org>; Sun, 28 Jun 2020 14:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=2FO6NofNmbXIQuOApZsMst63I5leCi/Oe4CvpNOsUhU=; b=S0dlFmxGAW5bDPkrEzfWQgpXZfodpdglVrJCOJn/F0Hr1XycaZMTY7W0taqdhHu0yj 6p0uG/eI37TZCNsALc+1Jc/svS5WKzEAUhPrb3SNfup1clm0WQ8qF//b9qx8moz/UXT8 fgzeu860sl+z4l82tBgeH7MDo3WqroRNiepSVQ5n2J2/WK7cOWWezacKonyeK20Vyj6w vlGWRTAGsGmviAUtO5zry3NbUONfdhuv/UU3NEjDOf3UfehcPdqYhcVvebKRL9CDtsnN P7q3eSM3NQw1Tzbe8miada9pyLJDW5y0CQ91zD1Iorx2x97q3tDtEENwUcfmKHsxN3Ov YEtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=2FO6NofNmbXIQuOApZsMst63I5leCi/Oe4CvpNOsUhU=; b=IKrxX1TSw8ghCWlg05JKRByxxsMpNncjuhqtfLPgCbf3FAlvs/94xI0mn3jh5xYKAT wlC1MOA62Kt3latihZe62netIowQ6AUEIm4uwWDhZni/uMvxmDWUI6euDn+B9Mdcj43J w6MwvWLU9fBJ+bJIsIOB7Iut7qkNJAdfb9o1aOkoHqtLWWpO31p4Z//bdH0C6bHQP2jo SKEGJ/UqZ7WNuOKYO/g4cYTm7X6gLfCohHBOhFRBpZJpdmTXERepzQ+AC0Nm9CKIHyM0 RMT+Cg3v6w5x1GFYNElq0LW6PicJmCTC3H9wzPiQQ4K0XwoYBT/asawoh/t/RgfQDVxg CGXA== X-Gm-Message-State: AOAM530QKlLNrnVX0zktNz0wvXUwa9ELs85g6MXItbUccQYOoZtNQY7H lrRRZ9b15xw+8u2r25nC9KQunbY7Qs4= X-Google-Smtp-Source: ABdhPJxs2wLut/vWIhkJ7t2/KXj2IvYU4vw/jU8IVjnEhbdHl+wOUifPi54KVqDhSaHcQLg/Nns1RQ== X-Received: by 2002:a17:906:2b50:: with SMTP id b16mr12059912ejg.410.1593381185805; Sun, 28 Jun 2020 14:53:05 -0700 (PDT) Received: from calancha-pc.dy.bbexcite.jp ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id v19sm21548992eda.70.2020.06.28.14.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jun 2020 14:53:04 -0700 (PDT) From: Tino Calancha To: Stefan Monnier Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> Date: Sun, 28 Jun 2020 23:52:57 +0200 In-Reply-To: (Stefan Monnier's message of "Sun, 28 Jun 2020 14:00:33 -0400") Message-ID: <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: Eli Zaretskii , uyennhi.qm@gmail.com, 38796@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sun, 28 Jun 2020, Drew Adams wrote: > OP here. I was waiting for you. Welcome!! :-) Stefan Monnier writes: > I agree that disabling should not necessarily be implemented by > "abusing" the max-lossage setting. Yeah, it was appealing to me at first look: the code was offering another feature for free! After your comments I rethink about it and become less excited: it always posible that we might be hit back in other parts of the code if they assume a 'sensible large enough' value. > But I don't see any reason to impose a 300 minimum either. I think it's > fine to impose a minimum, but it should be dictated by the limits of the > code. I'm not saying we should work to push this lower limit down, but > just that it should reflect what the code can do safely rather than > being an arbitrary number like 300 (I'm pretty sure 100 would be safe as > well, since that's what we've used for many years). Sure, 100 must be absolutely fine. I have updated the branch 'bug#38796-lossage-limit'. Now, the limit is not exposed to Lisp anymore. The function to update it now is a command 'update-lossage-size' We also have a 'lossage-size' function to retrieve its current value. --8<-----------------------------cut here---------------start------------->8--- commit c86d060b460bdaecdd71d297fa84012fcd397d66 Author: Tino Calancha Date: Sun Jun 28 23:30:07 2020 +0200 Do not expose the size of recent_keys to Lisp That prevents from unintentional crashes if the users modify the variable with setq or if they let-bind it. Users can still safely modify the lossage limit with the command `update-lossage-size'. For convenience, add a function `lossage-size' to return the current limit. * src/keyboard.c (lossage_limit): Do not expose it to Lisp; make it a static variable. Keep the current Emacs default (300); accept only values >= 100. (lossage-size): New function; it returns the current size of recent_keys. (update-lossage-size): Rename it from update-lossage-limit (all callers updated); make it a command. * doc/emacs/help.texi (Misc Help) * etc/NEWS * lisp/cus-start.el * lisp/edmacro.el * lisp/help.el: Update all references with the new name. * test/src/keyboard-tests.el (keyboard-lossage-limit): Amend the test. diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index e2c0dc6802..26cdf161d5 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -563,12 +563,14 @@ Misc Help @kindex C-h l @findex view-lossage -@vindex lossage-limit +@findex update-lossage-size +@findex lossage-size If something surprising happens, and you are not sure what you typed, use @kbd{C-h l} (@code{view-lossage}). @kbd{C-h l} displays your last input keystrokes and the commands they invoked. By default, Emacs -stores the last 300 events; if you wish, you can change this number -with the option @code{lossage-limit}. +stores the last 300 events; if you wish, you can change this number with +the command @code{update-lossage-size}. The function @code{lossage-size} +returns the current value for the lossage limit. If you see commands that you are not familiar with, you can use @kbd{C-h k} or @kbd{C-h f} to find out what they do. diff --git a/etc/NEWS b/etc/NEWS index da204c5825..5fc4cb4d87 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -71,8 +71,9 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". * Changes in Emacs 28.1 +++ -** The new option 'lossage-limit' controls the maximum number -of keystrokes and commands recorded. +** The new command 'update-lossage-size' allow users to set the maximum +number of keystrokes and commands recorded. The new function 'lossage-size' +returns the current value of this limit ** Support for '(box . SIZE)' 'cursor-type'. By default, 'box' cursor always has a filled box shape. But if you diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 1ebf554b2b..6632687da4 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -352,8 +352,6 @@ minibuffer-prompt-properties--setter ;; indent.c (indent-tabs-mode indent boolean) ;; keyboard.c - (lossage-limit keyboard integer "28.1" - :set (lambda (_ val) (update-lossage-limit val))) (meta-prefix-char keyboard character) (auto-save-interval auto-save integer) (auto-save-no-message auto-save boolean "27.1") diff --git a/lisp/edmacro.el b/lisp/edmacro.el index 089fea17ef..52cbf5b5a6 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -35,7 +35,7 @@ ;; * `M-x' followed by a command name, to edit a named command ;; whose definition is a keyboard macro. ;; -;; * `C-h l' (view-lossage), to edit the `lossage-limit' most recent +;; * `C-h l' (view-lossage), to edit the 300 most recent ;; keystrokes and install them as the "current" macro. ;; ;; * any key sequence whose definition is a keyboard macro. @@ -88,7 +88,7 @@ edit-kbd-macro "Edit a keyboard macro. At the prompt, type any key sequence which is bound to a keyboard macro. Or, type `\\[kmacro-end-and-call-macro]' or RET to edit the last -keyboard macro, `\\[view-lossage]' to edit the last `lossage-limit' +keyboard macro, `\\[view-lossage]' to edit the last 300 keystrokes as a keyboard macro, or `\\[execute-extended-command]' to edit a macro by its command name. With a prefix argument, format the macro in a more concise way." diff --git a/lisp/help.el b/lisp/help.el index 9e3d0922d0..01ee739a16 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -459,7 +459,7 @@ view-lossage "Display last input keystrokes and the commands run. For convenience this uses the same format as `edit-last-kbd-macro'. -See `lossage-limit' to update the number of recorded keystrokes. +See `update-lossage-size' to update the number of recorded keystrokes. To record all your input, use `open-dribble-file'." (interactive) diff --git a/src/keyboard.c b/src/keyboard.c index a4d27c94fb..29b157700c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -103,6 +103,7 @@ static KBOARD *all_kboards; /* True in the single-kboard state, false in the any-kboard state. */ static bool single_kboard; +/* Minimum allowed size of the recent_keys vector */ #define MIN_NUM_RECENT_KEYS (100) /* Index for storing next element into recent_keys. */ @@ -111,6 +112,9 @@ static int recent_keys_index; /* Total number of elements stored into recent_keys. */ static int total_keys; +/* Size of the recent_keys vector */ +static int lossage_limit = 3 * MIN_NUM_RECENT_KEYS; + /* This vector holds the last lossage_limit keystrokes. */ static Lisp_Object recent_keys; @@ -10411,6 +10415,15 @@ If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */) ? Qt : Qnil); } +DEFUN ("lossage-size", Flossage_size, Slossage_size, 0, 0, 0, + doc: /* Return the maximum number of saved keystrokes. +These are the records shown by `view-lossage'. */ ) + (void) +{ + return make_fixnum(lossage_limit); +} + +/* Reallocate recent_keys copying the keystrokes in the right order */ static void update_recent_keys (int new_size, int kept_keys) { @@ -10433,10 +10446,10 @@ update_recent_keys (int new_size, int kept_keys) } -/* Reallocate recent_keys copying the keystrokes in the right order */ -DEFUN ("update-lossage-limit", Fupdate_lossage_limit, - Supdate_lossage_limit, 1, 1, 0, +DEFUN ("update-lossage-size", Fupdate_lossage_size, + Supdate_lossage_size, 1, 1, "nnew-size: ", doc: /* Update the maximum number of saved keystrokes to ARG. +These are the records shown by `view-lossage'. usage: (update-lossage-limit ARG) */) (Lisp_Object arg) { @@ -11736,22 +11749,6 @@ syms_of_keyboard (void) staticpro (&modifier_symbols); } - DEFVAR_INT ("lossage-limit", lossage_limit, - doc: /* Maximum number of stored keyboard events and commands run. - -Please, do not set this variable in Lisp with `setq' neither -let-bind it, that will likely crash Emacs. This is because -`setq' only changes the variable, but it doesn't update -the size of the internal vector that holds the keystrokes. - -To update this variable use the customization menu, or -call from Lisp the following expression: - - (update-lossage-limit new-limit) - -That takes care of both, the variable and the internal vector.*/); - lossage_limit = 3 * MIN_NUM_RECENT_KEYS; - recent_keys = make_nil_vector (lossage_limit); staticpro (&recent_keys); @@ -11802,7 +11799,8 @@ That takes care of both, the variable and the internal vector.*/); defsubr (&Srecursive_edit); defsubr (&Sinternal_track_mouse); defsubr (&Sinput_pending_p); - defsubr (&Supdate_lossage_limit); + defsubr (&Slossage_size); + defsubr (&Supdate_lossage_size); defsubr (&Srecent_keys); defsubr (&Sthis_command_keys); defsubr (&Sthis_command_keys_vector); diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el index 017d239246..8f2cfe4adc 100644 --- a/test/src/keyboard-tests.el +++ b/test/src/keyboard-tests.el @@ -32,15 +32,15 @@ (read-event nil nil 2)) ?\C-b))) -(ert-deftest keyboard-lossage-limit () - "Test `lossage-limit' updates." - (dolist (val (list 100 100 200 500 300 1000 700)) - (update-lossage-limit val) - (should (= val lossage-limit))) - (let ((current-limit lossage-limit)) - (should-error (update-lossage-limit 5)) - (should-error (update-lossage-limit "200")) - (should (= lossage-limit current-limit)))) +(ert-deftest keyboard-lossage-size () + "Test `update-lossage-size'." + (dolist (val (list 100 300 400 400 500 1000 700 300)) + (update-lossage-size val) + (should (= val (lossage-size)))) + (let ((current-size (lossage-size))) + (should-error (update-lossage-size 5)) + (should-error (update-lossage-size "200")) + (should (= (lossage-size) current-size)))) (provide 'keyboard-tests) --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 28.0.50 (build 25, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0) of 2020-06-28 built on calancha-pc.dy.bbexcite.jp Repository revision: e13fd1fc373b35f510b70998bfddbb7af5989912 Repository branch: bug#38796-lossage-limit Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 28 20:07:59 2020 Received: (at 38796) by debbugs.gnu.org; 29 Jun 2020 00:07:59 +0000 Received: from localhost ([127.0.0.1]:47235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jphL4-00076Z-Tp for submit@debbugs.gnu.org; Sun, 28 Jun 2020 20:07:59 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56510) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jphL1-00076G-JC for 38796@debbugs.gnu.org; Sun, 28 Jun 2020 20:07:56 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05T07nZB033117; Mon, 29 Jun 2020 00:07:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=1xvxZy7S2roElhbls07iiQuyaLGcd1LTQY8NZmXwuBM=; b=CweS8YeIAVxjMHhNMQyE3i0xcZuA4FL4ZoVQP+yGUdV5xsJXcb/op3hQu6dym1uSPmcC pLJL+8iZILcPlbZEq1TkjLS1tLtK3MqTEZ9SQyHRX2QO5zayaC4BKiy0zhJ3e51i3kOT dq5gHDr4QHqjsQmlLt2EDCW1hu41pBp7juSoYlOtxtMfSgnVQc20nz6sLCZg5Gh6Ga82 /AmbVJRQUe3SutguNetpIIVq2Vmpr3tD2rtnXWC4Ak8qyEdUXorHiUYdR5rb/JcjNhyV 1KUa4f5CQ6P/0Da0KOx1Hx3GdjiG8maMYEBawh6Su43rf59+DYVSl88agsynZYFd18ba qg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 31xx1dgjvv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 29 Jun 2020 00:07:49 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05SNwQGU097738; Mon, 29 Jun 2020 00:07:49 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 31xfvq085u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Jun 2020 00:07:48 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05T07kqA017016; Mon, 29 Jun 2020 00:07:46 GMT MIME-Version: 1.0 Message-ID: <77c7c28a-dbd8-446e-93f8-9d1126fbc7fd@default> Date: Mon, 29 Jun 2020 00:05:45 +0000 (UTC) From: Drew Adams To: Tino Calancha , Stefan Monnier Subject: RE: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> In-Reply-To: <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5017.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9666 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=944 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006280180 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9666 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 adultscore=0 suspectscore=0 mlxlogscore=972 cotscore=-2147483648 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006280180 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: uyennhi.qm@gmail.com, 38796@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > > OP here. > I was waiting for you. Welcome!! :-) Sure, but the rest of your reply is a reply to Stefan's message, not mine. And the `>' quoting suggests you're quoting me in the rest of your message too, but you're quoting him. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 22 17:20:14 2020 Received: (at control) by debbugs.gnu.org; 22 Aug 2020 21:20:14 +0000 Received: from localhost ([127.0.0.1]:51608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9avt-0000PK-ST for submit@debbugs.gnu.org; Sat, 22 Aug 2020 17:20:14 -0400 Received: from quimby.gnus.org ([95.216.78.240]:39762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9avs-0000P4-0L for control@debbugs.gnu.org; Sat, 22 Aug 2020 17:20:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=c167idPwdsti/GkNe08lGCa5UdYKH03bXvsBQTklM5g=; b=JgvAgdVg+92xIT8jNXA/MSb7dq BLqgVyghfCTL6minGRUaWU6q0NoFNV3OiK4ak/+QPYrth/2N/E5JiaT56ewbTvCXYgymXlEQkGNC1 UbhMkNdWdwNF27rByDZGsWzg1xvJtEUe14pEpoZvEOCnE+eKCLVRq7Q/BBp0lQsZfc7s=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9avk-0007pR-8P for control@debbugs.gnu.org; Sat, 22 Aug 2020 23:20:06 +0200 Date: Sat, 22 Aug 2020 23:20:03 +0200 Message-Id: <87imdagyyk.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #38796 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 38796 + patch quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 38796 + patch quit From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 22 17:24:17 2020 Received: (at 38796) by debbugs.gnu.org; 22 Aug 2020 21:24:17 +0000 Received: from localhost ([127.0.0.1]:51617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9azp-0000W7-41 for submit@debbugs.gnu.org; Sat, 22 Aug 2020 17:24:17 -0400 Received: from quimby.gnus.org ([95.216.78.240]:39802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9azo-0000Vw-3I for 38796@debbugs.gnu.org; Sat, 22 Aug 2020 17:24:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Cc5Mi39a9v9VVwt5RcVYN9yKHMDfPnTnnvs7BTMTcKA=; b=t8lDLzr92RtGosGrsNEa8zjxWX Xr79l7zg19eRY74iuWR+Tjoy/UrbMbJgGLl+QScYjuCPyVZWxfSj42d+p3uAqCuQPsBDqdR9CQIC5 XBb2j6eV8qmckJjPr1eUQ33UiioTh8R2tbVuhduEEZm57I5yXSLa2tvffQIXZwB/ESns=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9azc-00080c-2f; Sat, 22 Aug 2020 23:24:09 +0200 From: Lars Ingebrigtsen To: Tino Calancha Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> X-Now-Playing: Tangerine Dream's _Zeit (1)_: "Origin of Supernatural Probabilities" Date: Sat, 22 Aug 2020 23:24:02 +0200 In-Reply-To: <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> (Tino Calancha's message of "Sun, 28 Jun 2020 23:52:57 +0200") Message-ID: <87eenygyrx.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Tino Calancha writes: >> I agree that disabling should not necessarily be implemented by >> "abusing" the max-lossage setting. > Yeah, it was appealing to me at first look: the code was offering > another feature for free! [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: Eli Zaretskii , Stefan Monnier , 38796@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Tino Calancha writes: >> I agree that disabling should not necessarily be implemented by >> "abusing" the max-lossage setting. > Yeah, it was appealing to me at first look: the code was offering > another feature for free! > After your comments I rethink about it and become less excited: it > always posible that we might be hit back in other parts of the code > if they assume a 'sensible large enough' value. I thought it sounded quite natural to use the same mechanism to switch lossage logging off. `(update-lossage-size 0)' seems like a natural thing to do to have no lossage. > Users can still safely modify the lossage limit with the > command `update-lossage-size'. For convenience, add > a function `lossage-size' to return the current limit. Hm... other functions use the convention of having a zero-parameter function return the data, and having a parameter to set it. So (lossage-size 500) could set it and (lossage-size) could return the current size? Anyway, it doesn't look like you've merged the branch? I think everybody was in favour of adding this feature. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 22 18:56:21 2020 Received: (at 38796) by debbugs.gnu.org; 22 Aug 2020 22:56:21 +0000 Received: from localhost ([127.0.0.1]:51712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9cQv-0004tt-3g for submit@debbugs.gnu.org; Sat, 22 Aug 2020 18:56:21 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:37198) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9cQt-0004tg-PB for 38796@debbugs.gnu.org; Sat, 22 Aug 2020 18:56:20 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07MMplsk035956; Sat, 22 Aug 2020 22:56:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=d70q9WL5NpdLr4RlPQduMSNZp6FDr1Dl5hiNXSmMYgo=; b=h4FUO1aRkzCEc+K/R7A6lOYKjEAvCr0q+3ni+9GNyPqguDy+QUtJw15PMEg4hlnSGGXc x/qHIYpdF65lJdmLpIh9CKmfNtomURBC9W9p43i9EzOSQtW3KZ3ebZcMDdtQaWoPc9SQ erKjGKwzhCuLk4u8sRidCRQqvZhONOQY85yAk6SFejo1VarS3Y2FcAan9GCeX5QnY0El RCsZ6m2uoXkdP/5r97YpT7pQA5i73I1+uiQ3Ss9vtDwrrUEfJjp9PYybFrhP1B+Ue9Oa 120rDbzDlNejacLcokTTY9xKI/YSia/THCcOT/M482b25XfRbKBDMI8hxTwxz2ayOuAU qw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 332uak9q0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 22 Aug 2020 22:56:13 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07MMrwDi031212; Sat, 22 Aug 2020 22:54:13 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 332u6151rd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 22 Aug 2020 22:54:13 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07MMsBnp014888; Sat, 22 Aug 2020 22:54:11 GMT MIME-Version: 1.0 Message-ID: <00e30775-94b9-4663-a823-296bad355dcf@default> Date: Sat, 22 Aug 2020 15:54:09 -0700 (PDT) From: Drew Adams To: Lars Ingebrigtsen , Tino Calancha Subject: RE: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> <87eenygyrx.fsf@gnus.org> In-Reply-To: <87eenygyrx.fsf@gnus.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5044.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9721 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008220254 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9721 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 clxscore=1011 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 phishscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008220254 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: Stefan Monnier , 38796@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I thought it sounded quite natural to use the same mechanism to switch > lossage logging off. `(update-lossage-size 0)' seems like a natural > thing to do to have no lossage. FWIW, I said the same thing: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D38796#28 It's not unusual or weird for a zero-valued size parameter to have such an effect.=20 > > Users can still safely modify the lossage limit with the > > command `update-lossage-size'. For convenience, add > > a function `lossage-size' to return the current limit. >=20 > Hm... other functions use the convention of having a zero-parameter > function return the data, and having a parameter to set it. So > (lossage-size 500) could set it and (lossage-size) could return the > current size? FWIW, most `set-*' functions are commands. And a command is what we should shoot for here. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 27 17:28:14 2020 Received: (at 38796) by debbugs.gnu.org; 27 Aug 2020 21:28:14 +0000 Received: from localhost ([127.0.0.1]:44329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBPRO-0002iS-2F for submit@debbugs.gnu.org; Thu, 27 Aug 2020 17:28:14 -0400 Received: from mail-wm1-f45.google.com ([209.85.128.45]:52552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBPRL-0002iD-CJ for 38796@debbugs.gnu.org; Thu, 27 Aug 2020 17:28:12 -0400 Received: by mail-wm1-f45.google.com with SMTP id q9so4285925wmj.2 for <38796@debbugs.gnu.org>; Thu, 27 Aug 2020 14:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=YW/2ut4wTEL0trkClAWJIGaBzxN+D2oMxOMS1ZRisiE=; b=n38GtVrl41WlGgHFaMmR6fJhWoZ/STv2Y0ugDGNjcW5IyAs9d37tCt/M3OfG5NDXnl DHjYYSWJUcs4BiBoeImmbcphE1Qf1iRFwIKk4JeRL0p+7q7vsq63RHqJ3j6G/Hmccl7u me4QSC0QMDuOTXxJ6rCLDGDzOWQ0tcqqHQxPjo9iQzGcfXB4VWFBFBT8V7Fl8pcElpzD cnjpE8QJUkkYmx6fZNNYeuwupd4/RcGYbXmvpXUzLdIWY8dChOVE5ud9nrYJ7qyE/jwg MkBtcwQozvW+Za8n7uidZOWVl1SPgfvuIGpwclL9ng0kmQbtbjC5+gI63O0G/gqkmtHZ KFfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=YW/2ut4wTEL0trkClAWJIGaBzxN+D2oMxOMS1ZRisiE=; b=Jd6WIygpu5Wm1qtQL+c4bQrjKgOTrHUgP43hRAbZbZFSABwwgid9Qo7Nt5zbK4EQEr Yfjx57OG9bmSMD2oy5YToNRm/8y6uosM4fcoVzFMkZPJDuMYUGg5jh0rA5GuPUfcfCoY WYZwD1AqZ0s8QhzsDvg4Q7S2KBzpdH2Zqh7hwFIbDY1VQSq0JJVGXJd8e3LffUoqRRTm gNC1iePAsLvNSvUW2ddwxre2j3oif//F10ePGdKoj0pIj4rAOSp4RA5kkvbAJLxjRpFj C4yh2aHEt8dRRtMS86FjkPBMsEHVjXc1wNz4sfKvZMTXN0NaAV4TTmgD1FCbvkAePZep JdHQ== X-Gm-Message-State: AOAM530QHXCsyNMZZKuIIc+TD8YSVvP7WryDtmVaacWAK63hcK7Iz4KF 7vDXpIPgjLfUTfy1JSf25HA= X-Google-Smtp-Source: ABdhPJyo8wNhoe6ahuiW4kjghmYyBC+5scoEYofS2HuoEzQG79VmAKJRcLk5ra6TkRWNVLcqT4+SUQ== X-Received: by 2002:a1c:cc0c:: with SMTP id h12mr696761wmb.57.1598563685460; Thu, 27 Aug 2020 14:28:05 -0700 (PDT) Received: from localhost.example.com (64.red-83-58-61.dynamicip.rima-tde.net. [83.58.61.64]) by smtp.gmail.com with ESMTPSA id g16sm8615183wrs.88.2020.08.27.14.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2020 14:28:04 -0700 (PDT) From: Tino Calancha To: Lars Ingebrigtsen Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> <87eenygyrx.fsf@gnus.org> Date: Thu, 27 Aug 2020 23:28:03 +0200 In-Reply-To: <87eenygyrx.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 22 Aug 2020 23:24:02 +0200") Message-ID: <87d03beq3g.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: Eli Zaretskii , stefankangas@gmail.com, Stefan Monnier , 38796@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > Tino Calancha writes: > >>> I agree that disabling should not necessarily be implemented by >>> "abusing" the max-lossage setting. >> Yeah, it was appealing to me at first look: the code was offering >> another feature for free! >> After your comments I rethink about it and become less excited: it >> always posible that we might be hit back in other parts of the code >> if they assume a 'sensible large enough' value. > > I thought it sounded quite natural to use the same mechanism to switch > lossage logging off. `(update-lossage-size 0)' seems like a natural > thing to do to have no lossage. > Anyway, it doesn't look like you've merged the branch? I think > everybody was in favour of adding this feature. People agree with that. The friction arises because I kept the current implementation, which can be seen as abusing on it, and/or risky. [ I have neither plan nor time to redo the current implementation. ] >> Users can still safely modify the lossage limit with the >> command `update-lossage-size'. For convenience, add >> a function `lossage-size' to return the current limit. > > Hm... other functions use the convention of having a zero-parameter > function return the data, and having a parameter to set it. So > (lossage-size 500) could set it and (lossage-size) could return the > current size? I have amended the patch to do this. Thank you. FWIW I have been running Emacs almost 3 months using this branch with no issues. If Eli is OK with it, I can merge it to master next week. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 28 02:04:24 2020 Received: (at 38796) by debbugs.gnu.org; 28 Aug 2020 06:04:24 +0000 Received: from localhost ([127.0.0.1]:44897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBXUu-0000e3-6A for submit@debbugs.gnu.org; Fri, 28 Aug 2020 02:04:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53076) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBXUs-0000dr-Ae for 38796@debbugs.gnu.org; Fri, 28 Aug 2020 02:04:22 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40658) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBXUm-0006By-HE; Fri, 28 Aug 2020 02:04:16 -0400 Received: from [176.228.60.248] (port=2228 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kBXUl-0003dr-Tb; Fri, 28 Aug 2020 02:04:16 -0400 Date: Fri, 28 Aug 2020 09:04:06 +0300 Message-Id: <83zh6fz4q1.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-Reply-To: <87d03beq3g.fsf@gmail.com> (message from Tino Calancha on Thu, 27 Aug 2020 23:28:03 +0200) Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> <87eenygyrx.fsf@gnus.org> <87d03beq3g.fsf@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: larsi@gnus.org, stefankangas@gmail.com, monnier@iro.umontreal.ca, 38796@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Tino Calancha > Cc: Eli Zaretskii , Stefan Monnier > , 38796@debbugs.gnu.org, uyennhi.qm@gmail.com, > stefankangas@gmail.com > Date: Thu, 27 Aug 2020 23:28:03 +0200 > > People agree with that. The friction arises because I kept the current > implementation, which can be seen as abusing on it, and/or risky. > [ I have neither plan nor time to redo the current implementation. ] > >> Users can still safely modify the lossage limit with the > >> command `update-lossage-size'. For convenience, add > >> a function `lossage-size' to return the current limit. > > > > Hm... other functions use the convention of having a zero-parameter > > function return the data, and having a parameter to set it. So > > (lossage-size 500) could set it and (lossage-size) could return the > > current size? > I have amended the patch to do this. Thank you. > > FWIW I have been running Emacs almost 3 months using this branch > with no issues. > If Eli is OK with it, I can merge it to master next week. Sorry, OK with what? where's the patch which I should agree with? From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 04 05:31:46 2020 Received: (at 38796) by debbugs.gnu.org; 4 Sep 2020 09:31:46 +0000 Received: from localhost ([127.0.0.1]:37454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kE84P-00014j-B0 for submit@debbugs.gnu.org; Fri, 04 Sep 2020 05:31:45 -0400 Received: from mail-wm1-f50.google.com ([209.85.128.50]:36772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kE84M-00014S-On for 38796@debbugs.gnu.org; Fri, 04 Sep 2020 05:31:43 -0400 Received: by mail-wm1-f50.google.com with SMTP id z9so5439025wmk.1 for <38796@debbugs.gnu.org>; Fri, 04 Sep 2020 02:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=YEBpsYM5Y66jt+tp7qMunO0Bn6ahLE6qPzmPBgf9iBc=; b=oeVaNVNQuykrcfswPk7uoAmN1h5wG+hNHgyD8/hFyerlkGAUfX7Df+S/qaRi2GLbUF 2SitiIcrVHEUGJ8oWy+5jGArMbzTHxdI3Hv4+LO//huKSeobeCvdjRVQySguT5B//MFJ 03vIyuVesyTskJ/wr9rOsuM1rkWguOerl0LsVfc2XrppQSII6E/9IY81emF7ei5atN6x CCTtKkpviy2dnx5M0XFr1EBY6zVs7+FgktwLaIiTEkJ81W62HafI8mQ4X+S3Dl++o7Pn +NPYky3NE11+H+GGJvNgrmmfT6qCz5xDw3tBoXui6tRfi11qZ2YAr2NuNddvE5YgXFmB fG1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=YEBpsYM5Y66jt+tp7qMunO0Bn6ahLE6qPzmPBgf9iBc=; b=husP88T7rBhcCOd/hz8O8xMmrzlKDPAvXkr0CeuH1s6OtXMoyQLPPVD2sHa/voQvpi RajOvAPJgiIr2//z+m0Q4iRWfYw9YEOAG39oOiifWx9Wm9BDNSeGWFgDZylUpIuM7XzD iIaVogwK6huvWym14e20peo9DoMdm8ONukYThHjUBQVB09A6r7qx+AQKDXV630I0nuz7 Hqg668l2doveZDZuM5yfRVU6mfjtaUu44YjMYJ/1kHK7MdgR5QNuTppsQ6zhNJyleaOZ O6PtCEaT0T2ucWX5ANajFo8EcNd+d+Qy5kh6y2x5sFjJDaLxS8pLNjciBYxAU/gZoGbH w+nw== X-Gm-Message-State: AOAM533PZrhs6qdHqyeWZ5zwL9roIn0gfJSKoOWhIYnu5D1bacSrRdx1 pxmu6ujC+h4fgPGiqYwyBos= X-Google-Smtp-Source: ABdhPJxHWaAB7gImOIxWQMUTAcFKw3UFW8RpRy26lKw27Z01oQ68IGljLFH0cG/er8TD0qud8p5w1g== X-Received: by 2002:a1c:4455:: with SMTP id r82mr6598904wma.60.1599211895647; Fri, 04 Sep 2020 02:31:35 -0700 (PDT) Received: from localhost.example.com (64.red-83-58-61.dynamicip.rima-tde.net. [83.58.61.64]) by smtp.gmail.com with ESMTPSA id o4sm9878486wrv.86.2020.09.04.02.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 02:31:34 -0700 (PDT) From: Tino Calancha To: Eli Zaretskii Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> <87eenygyrx.fsf@gnus.org> <87d03beq3g.fsf@gmail.com> <83zh6fz4q1.fsf@gnu.org> Date: Fri, 04 Sep 2020 11:31:33 +0200 In-Reply-To: <83zh6fz4q1.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 28 Aug 2020 09:04:06 +0300") Message-ID: <87363xj3be.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: uyennhi.qm@gmail.com, larsi@gnus.org, stefankangas@gmail.com, 38796@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> FWIW I have been running Emacs almost 3 months using this branch >> with no issues. >> If Eli is OK with it, I can merge it to master next week. > > Sorry, OK with what? where's the patch which I should agree with? Branch origin/bug#38796-lossage-limit The following is the difference with master branch when I updated the branch (last August 27th): --8<-----------------------------cut here---------------start------------->8--- diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index 06ad5a583d..34a354891b 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -573,10 +573,13 @@ Misc Help @kindex C-h l @findex view-lossage +@findex lossage-size If something surprising happens, and you are not sure what you typed, use @kbd{C-h l} (@code{view-lossage}). @kbd{C-h l} displays your last -300 input keystrokes and the commands they invoked. If you see -commands that you are not familiar with, you can use @kbd{C-h k} or +input keystrokes and the commands they invoked. By default, Emacs +stores the last 300 events; if you wish, you can change this number with +the command @code{lossage-size}. +If you see commands that you are not familiar with, you can use @kbd{C-h k} or @kbd{C-h f} to find out what they do. @kindex C-h e diff --git a/etc/NEWS b/etc/NEWS index 964b626d7b..8bb3527d85 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -85,6 +85,10 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". * Changes in Emacs 28.1 ++++ +** The new command 'lossage-limit' controls the maximum number +of keystrokes and commands recorded. + +++ ** New variables that hold default buffer names for shell output. The new constants 'shell-command-buffer-name' and @@ -92,6 +96,9 @@ The new constants 'shell-command-buffer-name' and for the output of, respectively, synchronous and async shell commands. +** The new command lossage-size' allow users to set the maximum +number of keystrokes and commands recorded. + ** Support for '(box . SIZE)' 'cursor-type'. By default, 'box' cursor always has a filled box shape. But if you specify 'cursor-type' to be '(box . SIZE)', the cursor becomes a hollow diff --git a/lisp/comint.el b/lisp/comint.el index be0e32b9e0..afc8395b36 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2393,7 +2393,7 @@ comint-send-invisible Then send it to the process running in the current buffer. The string is sent using `comint-input-sender'. Security bug: your string can still be temporarily recovered with -\\[view-lossage]; `clear-this-command-keys' can fix that." +\\[view-lossage]; `clear-this-command-keys' and `lossage-size' can fix that." (interactive "P") ; Defeat snooping via C-x ESC ESC (let ((proc (get-buffer-process (current-buffer))) (prefix diff --git a/lisp/edmacro.el b/lisp/edmacro.el index 71474c0289..52cbf5b5a6 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -35,8 +35,8 @@ ;; * `M-x' followed by a command name, to edit a named command ;; whose definition is a keyboard macro. ;; -;; * `C-h l' (view-lossage), to edit the 300 most recent keystrokes -;; and install them as the "current" macro. +;; * `C-h l' (view-lossage), to edit the 300 most recent +;; keystrokes and install them as the "current" macro. ;; ;; * any key sequence whose definition is a keyboard macro. ;; diff --git a/lisp/help.el b/lisp/help.el index 1b0149616f..d3b0e02f08 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -455,9 +455,10 @@ view-external-packages (info "(efaq)Packages that do not come with Emacs")) (defun view-lossage () - "Display last few input keystrokes and the commands run. + "Display last input keystrokes and the commands run. For convenience this uses the same format as `edit-last-kbd-macro'. +See `lossage-size' to update the number of recorded keystrokes. To record all your input, use `open-dribble-file'." (interactive) diff --git a/lisp/term.el b/lisp/term.el index e77c2c1331..e39d03e8cd 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -2236,7 +2236,8 @@ term-read-noecho Note that the keystrokes comprising the text can still be recovered \(temporarily) with \\[view-lossage]. This may be a security bug for some -applications." +applications. See `clear-this-command-keys' and `lossage-size' for ways +to fix that." (declare (obsolete read-passwd "27.1")) (let ((ans "") (c 0) diff --git a/src/keyboard.c b/src/keyboard.c index 5fa58abce1..bf8d75b602 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -103,15 +103,16 @@ Copyright (C) 1985-1989, 1993-1997, 1999-2020 Free Software Foundation, /* True in the single-kboard state, false in the any-kboard state. */ static bool single_kboard; -#define NUM_RECENT_KEYS (300) - /* Index for storing next element into recent_keys. */ static int recent_keys_index; /* Total number of elements stored into recent_keys. */ static int total_keys; -/* This vector holds the last NUM_RECENT_KEYS keystrokes. */ +/* Size of the recent_keys vector */ +static int lossage_limit = 300; + +/* This vector holds the last lossage_limit keystrokes. */ static Lisp_Object recent_keys; /* Vector holding the key sequence that invoked the current command. @@ -294,6 +295,7 @@ #define GROW_RAW_KEYBUF \ /* Pointer to next place to store character in kbd_buffer. */ static union buffered_input_event *kbd_store_ptr; + /* The above pair of variables forms a "queue empty" flag. When we enqueue a non-hook event, we increment kbd_store_ptr. When we dequeue a non-hook event, we increment kbd_fetch_ptr. We say that @@ -1421,10 +1423,10 @@ command_loop_1 (void) /* Execute the command. */ { - total_keys += total_keys < NUM_RECENT_KEYS; + total_keys += total_keys < lossage_limit; ASET (recent_keys, recent_keys_index, Fcons (Qnil, cmd)); - if (++recent_keys_index >= NUM_RECENT_KEYS) + if (++recent_keys_index >= lossage_limit) recent_keys_index = 0; } Vthis_command = cmd; @@ -3248,15 +3250,15 @@ record_char (Lisp_Object c) int ix1, ix2, ix3; if ((ix1 = recent_keys_index - 1) < 0) - ix1 = NUM_RECENT_KEYS - 1; + ix1 = lossage_limit - 1; ev1 = AREF (recent_keys, ix1); if ((ix2 = ix1 - 1) < 0) - ix2 = NUM_RECENT_KEYS - 1; + ix2 = lossage_limit - 1; ev2 = AREF (recent_keys, ix2); if ((ix3 = ix2 - 1) < 0) - ix3 = NUM_RECENT_KEYS - 1; + ix3 = lossage_limit - 1; ev3 = AREF (recent_keys, ix3); if (EQ (XCAR (c), Qhelp_echo)) @@ -3307,12 +3309,12 @@ record_char (Lisp_Object c) { if (!recorded) { - total_keys += total_keys < NUM_RECENT_KEYS; + total_keys += total_keys < lossage_limit; ASET (recent_keys, recent_keys_index, /* Copy the event, in case it gets modified by side-effect by some remapping function (bug#30955). */ CONSP (c) ? Fcopy_sequence (c) : c); - if (++recent_keys_index >= NUM_RECENT_KEYS) + if (++recent_keys_index >= lossage_limit) recent_keys_index = 0; } else if (recorded < 0) @@ -3326,10 +3328,10 @@ record_char (Lisp_Object c) while (recorded++ < 0 && total_keys > 0) { - if (total_keys < NUM_RECENT_KEYS) + if (total_keys < lossage_limit) total_keys--; if (--recent_keys_index < 0) - recent_keys_index = NUM_RECENT_KEYS - 1; + recent_keys_index = lossage_limit - 1; ASET (recent_keys, recent_keys_index, Qnil); } } @@ -10410,6 +10412,62 @@ DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 1, 0, ? Qt : Qnil); } +/* Reallocate recent_keys copying the keystrokes in the right order */ +static void +update_recent_keys (int new_size, int kept_keys) +{ + int osize = ASIZE (recent_keys); + eassert (recent_keys_index < osize); + eassert (kept_keys <= min (osize, new_size)); + Lisp_Object v = make_nil_vector (new_size); + int i, idx; + for (i = 0; i < kept_keys; ++i) + { + idx = recent_keys_index - kept_keys + i; + while (idx < 0) + idx += osize; + ASET (v, i, AREF (recent_keys, idx)); + } + recent_keys = v; + total_keys = kept_keys; + recent_keys_index = total_keys % new_size; + lossage_limit = new_size; + +} + +DEFUN ("lossage-size", Flossage_size, Slossage_size, 0, 1, + "(list (read-number \"new-size: \" (lossage-size)))", + doc: /* Return the maximum number of saved keystrokes. +Called with ARG, then set this number to ARG. + +The saved keystrokes are the records shown by `view-lossage'. +If you want to disable the lossage records, then set this maximum to a +small number, e.g. 0. +usage: (lossage-size &optional ARG) */) + (Lisp_Object arg) +{ + if (NILP(arg)) + return make_fixnum(lossage_limit == 1 ? 0 : lossage_limit); + + if (!FIXNATP (arg)) + user_error ("Value must be a non-negative integer"); + int osize = ASIZE (recent_keys); + eassert (lossage_limit == osize); + int new_size = XFIXNAT (arg); + + if (new_size == osize) + return Qnil; + /* Internally, the minimum lossage_limit is 1; users will likely use + 0 to disable the lossage, thus here we change 0 -> 1. */ + if (new_size == 0) + new_size = 1; + + int kept_keys = new_size > osize ? total_keys : min (new_size, total_keys); + update_recent_keys (new_size, kept_keys); + + return Qnil; +} + DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, doc: /* Return vector of last few events, not counting those from keyboard macros. If INCLUDE-CMDS is non-nil, include the commands that were run, @@ -10419,21 +10477,21 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, bool cmds = !NILP (include_cmds); if (!total_keys - || (cmds && total_keys < NUM_RECENT_KEYS)) + || (cmds && total_keys < lossage_limit)) return Fvector (total_keys, XVECTOR (recent_keys)->contents); else { Lisp_Object es = Qnil; - int i = (total_keys < NUM_RECENT_KEYS + int i = (total_keys < lossage_limit ? 0 : recent_keys_index); - eassert (recent_keys_index < NUM_RECENT_KEYS); + eassert (recent_keys_index < lossage_limit); do { Lisp_Object e = AREF (recent_keys, i); if (cmds || !CONSP (e) || !NILP (XCAR (e))) es = Fcons (e, es); - if (++i >= NUM_RECENT_KEYS) + if (++i >= lossage_limit) i = 0; } while (i != recent_keys_index); es = Fnreverse (es); @@ -10531,7 +10589,7 @@ DEFUN ("this-single-command-raw-keys", Fthis_single_command_raw_keys, DEFUN ("clear-this-command-keys", Fclear_this_command_keys, Sclear_this_command_keys, 0, 1, 0, doc: /* Clear out the vector that `this-command-keys' returns. -Also clear the record of the last 300 input events, unless optional arg +Also clear the record of the last input events, unless optional arg KEEP-RECORD is non-nil. */) (Lisp_Object keep_record) { @@ -11686,7 +11744,7 @@ syms_of_keyboard (void) staticpro (&modifier_symbols); } - recent_keys = make_nil_vector (NUM_RECENT_KEYS); + recent_keys = make_nil_vector (lossage_limit); staticpro (&recent_keys); this_command_keys = make_nil_vector (40); @@ -11736,6 +11794,7 @@ syms_of_keyboard (void) defsubr (&Srecursive_edit); defsubr (&Sinternal_track_mouse); defsubr (&Sinput_pending_p); + defsubr (&Slossage_size); defsubr (&Srecent_keys); defsubr (&Sthis_command_keys); defsubr (&Sthis_command_keys_vector); diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el index 1988ba51a7..d4ac4a518d 100644 --- a/test/src/keyboard-tests.el +++ b/test/src/keyboard-tests.el @@ -32,5 +32,23 @@ keyboard-unread-command-events (read-event nil nil 2)) ?\C-b))) +(ert-deftest keyboard-lossage-size () + "Test `lossage-size'." + (dolist (val (list 100 300 400 400 500 1000 700 300)) + (lossage-size val) + (should (= val (lossage-size)))) + (let ((current-size (lossage-size))) + ;; Set lossage size to 1 and 0 are equivalent + (lossage-size 0) + (should (zerop (lossage-size))) + (lossage-size 1) + (should (zerop (lossage-size))) + (lossage-size current-size) + ;; Argument must be a natural number + (should-error (lossage-size -5)) + (should-error (lossage-size "200")) + (should (= (lossage-size) current-size)))) + + (provide 'keyboard-tests) ;;; keyboard-tests.el ends here --8<-----------------------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 04 08:08:12 2020 Received: (at 38796) by debbugs.gnu.org; 4 Sep 2020 12:08:12 +0000 Received: from localhost ([127.0.0.1]:37708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEAVn-0007S2-R1 for submit@debbugs.gnu.org; Fri, 04 Sep 2020 08:08:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEAVk-0007Ro-A0 for 38796@debbugs.gnu.org; Fri, 04 Sep 2020 08:08:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40281) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEAVe-0000ZW-KV; Fri, 04 Sep 2020 08:08:02 -0400 Received: from [176.228.60.248] (port=1830 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kEAVd-00032I-K8; Fri, 04 Sep 2020 08:08:02 -0400 Date: Fri, 04 Sep 2020 15:07:50 +0300 Message-Id: <83o8mlu4mh.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-Reply-To: <87363xj3be.fsf@gmail.com> (message from Tino Calancha on Fri, 04 Sep 2020 11:31:33 +0200) Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> <87eenygyrx.fsf@gnus.org> <87d03beq3g.fsf@gmail.com> <83zh6fz4q1.fsf@gnu.org> <87363xj3be.fsf@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38796 Cc: uyennhi.qm@gmail.com, larsi@gnus.org, stefankangas@gmail.com, 38796@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Tino Calancha > Cc: larsi@gnus.org, stefankangas@gmail.com, monnier@iro.umontreal.ca, > 38796@debbugs.gnu.org, uyennhi.qm@gmail.com > Date: Fri, 04 Sep 2020 11:31:33 +0200 > > Eli Zaretskii writes: > > >> FWIW I have been running Emacs almost 3 months using this branch > >> with no issues. > >> If Eli is OK with it, I can merge it to master next week. > > > > Sorry, OK with what? where's the patch which I should agree with? > > Branch origin/bug#38796-lossage-limit > > The following is the difference with master branch when I updated > the branch (last August 27th): Not sure what that means. Is this the patch you suggest installing, or does it need more work to adapt it to the current master? > If something surprising happens, and you are not sure what you typed, > use @kbd{C-h l} (@code{view-lossage}). @kbd{C-h l} displays your last > -300 input keystrokes and the commands they invoked. If you see > -commands that you are not familiar with, you can use @kbd{C-h k} or > +input keystrokes and the commands they invoked. By default, Emacs > +stores the last 300 events; if you wish, you can change this number with ^^^^^^^^^^^^^^^ The first sentence talks about keystrokes, but the last sentence talks about "events". The reader might become confused whether these two terms refer to the same entity. > ++++ > +** The new command 'lossage-limit' controls the maximum number > +of keystrokes and commands recorded. > + > +++ > ** New variables that hold default buffer names for shell output. > The new constants 'shell-command-buffer-name' and > @@ -92,6 +96,9 @@ The new constants 'shell-command-buffer-name' and > for the output of, respectively, synchronous and async shell > commands. > > +** The new command lossage-size' allow users to set the maximum Missing opening quote for lossage-size. > +number of keystrokes and commands recorded. NEWS mentions 2 separate commands, but I see only one in the implementation. > --- a/lisp/edmacro.el > +++ b/lisp/edmacro.el > @@ -35,8 +35,8 @@ > ;; * `M-x' followed by a command name, to edit a named command > ;; whose definition is a keyboard macro. > ;; > -;; * `C-h l' (view-lossage), to edit the 300 most recent keystrokes > -;; and install them as the "current" macro. > +;; * `C-h l' (view-lossage), to edit the 300 most recent > +;; keystrokes and install them as the "current" macro. This change is a no-op; why is it needed? > (defun view-lossage () > - "Display last few input keystrokes and the commands run. > + "Display last input keystrokes and the commands run. Why this change? > -/* This vector holds the last NUM_RECENT_KEYS keystrokes. */ > +/* Size of the recent_keys vector */ ^^^ A comment should end in a period and 2 spaces before "*/". > /* Pointer to next place to store character in kbd_buffer. */ > static union buffered_input_event *kbd_store_ptr; > > + Do we really need to add an empty line here? > +DEFUN ("lossage-size", Flossage_size, Slossage_size, 0, 1, > + "(list (read-number \"new-size: \" (lossage-size)))", > + doc: /* Return the maximum number of saved keystrokes. The first line describes only one of the two functionalities of this command; it should describe both. > +Called with ARG, then set this number to ARG. "ARG non-nil means set the maximum number of keystrokes to that number." > +The saved keystrokes are the records shown by `view-lossage'. > +If you want to disable the lossage records, then set this maximum to a > +small number, e.g. 0. The "small number, e.g." part is inaccurate: it _must_ be zero, right? > +usage: (lossage-size &optional ARG) */) Is this "usage" needed? what happens if you don't use it? > + if (NILP(arg)) > + return make_fixnum(lossage_limit == 1 ? 0 : lossage_limit); ^ Space here. So if the user sets the limit to 1, the next call to lossage-size will return zero? Isn't that confusing? > + /* Internally, the minimum lossage_limit is 1; users will likely use > + 0 to disable the lossage, thus here we change 0 -> 1. */ > + if (new_size == 0) > + new_size = 1; I still don't like this. I think it will cause confusion and errors. > + return Qnil; Why return nil when setting the limit? why not the previous limit? > +(ert-deftest keyboard-lossage-size () > + "Test `lossage-size'." > + (dolist (val (list 100 300 400 400 500 1000 700 300)) > + (lossage-size val) > + (should (= val (lossage-size)))) This doesn't test the actual recording of VAL events. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 12 08:29:58 2020 Received: (at 38796) by debbugs.gnu.org; 12 Sep 2020 12:29:58 +0000 Received: from localhost ([127.0.0.1]:46549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kH4fF-0000WM-W3 for submit@debbugs.gnu.org; Sat, 12 Sep 2020 08:29:58 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:35154) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kH4fC-0000W7-AE for 38796@debbugs.gnu.org; Sat, 12 Sep 2020 08:29:56 -0400 Received: by mail-ed1-f68.google.com with SMTP id i1so13111108edv.2 for <38796@debbugs.gnu.org>; Sat, 12 Sep 2020 05:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=5t5HmW2X8yQzzxHQOcalBJ7Xle1+vDddC5683nvM7fI=; b=jaCaQtfN7t6qa1qP4OrYWZO3zJpOUKg4u2CO1z9Yb5a7PQHbjfH5zPBDiLpHpGjxv1 AvGb05OUkal2FrHLM2LqG3F+iy/QOSpWDa6EvAZidUV7xOL9vmzC0QBxx4dUwQbflJ94 BpKvArUcHGBMMxanr0yh/FyGto9jzJbyRkS8ehHvDPIvAE4K8sXPB3HdKPXiLYk4OCwU tRLM4vvElF0Ok18AyxkZbzDiGxjcHhCBBBjH7z+DVVhoghOqDL+pQeXlZyRZw5Vyc1oy FmLpNP3TZxI3JcuuyYrOjoZL4Wh68o0N9SE0aDj2dXw6LNXLL8T3evpLSRwaAeqOzURq Knmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=5t5HmW2X8yQzzxHQOcalBJ7Xle1+vDddC5683nvM7fI=; b=BuTu4ZOrcKSWRTCm8tstZAR5jeK6XZ1hAjwrEt7dAx4niqc1JG+4aTQrm/1zgxnXrQ oeXVBVvu+QOUf0e/V3Yk1j0qpyahItVCACratYdQwKohxO0wUkVZF+3uA+D2Bj02BTD3 R6gEvhY0Brgt+lHJZaShg3xmJXoMnhgWpKsNujQ8bR3VbOgapK2VJK46GzGb20hCYfM4 s/ttRGq32RkuURlDvkxhRzTlddfnTh7xzmcRBasZbGV67xJVJLR3BXM8L3tv5Ekx7ctp yh2UVmBvbRtqoNU1bK0/jS84fkYpECpEdfkPIytyDd1G+F9HyoJUzAA88auZY7li68vh SfqA== X-Gm-Message-State: AOAM532BePh1SmlzzibU/ySNwlrPhzbcMwHOXCC60/K8hL8q+2QLeD6i pN+xSj1kDhEM9bVW6mxu3S0= X-Google-Smtp-Source: ABdhPJy+UkUPrQtvjGZfHr8DQ4+6Z2Vn0fEWrbWLWOk6swV7pLUkQ6u/dm0y0TzaZoLAb0ju3B+hKA== X-Received: by 2002:a05:6402:144c:: with SMTP id d12mr8250541edx.168.1599913788251; Sat, 12 Sep 2020 05:29:48 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id f10sm4477607edk.34.2020.09.12.05.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 05:29:47 -0700 (PDT) From: Tino Calancha To: Eli Zaretskii Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> <87eenygyrx.fsf@gnus.org> <87d03beq3g.fsf@gmail.com> <83zh6fz4q1.fsf@gnu.org> <87363xj3be.fsf@gmail.com> <83o8mlu4mh.fsf@gnu.org> Date: Sat, 12 Sep 2020 14:29:45 +0200 In-Reply-To: <83o8mlu4mh.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 04 Sep 2020 15:07:50 +0300") Message-ID: <87blibdvpi.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: larsi@gnus.org, monnier@iro.umontreal.ca, uyennhi.qm@gmail.com, 38796@debbugs.gnu.org, stefankangas@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: Thank you for the review Eli. I have fixed all your comments. Regarding the feature to disable the recording of keystrokes, I am not happy with my hackish implementation either: I have dropped it. I prefer just to keep my patch within the scope of the original proposal: i.e., be able to set the lossage limit with Lisp (within well tested limits). I am glad to push the following patch next week if there are no complaints. --8<-----------------------------cut here---------------start------------->8--- commit bee193a5d6cd7889183cf811eb001e0071052724 Author: Tino Calancha Date: Sat Sep 12 14:14:45 2020 +0200 Give Lisp control on the lossage size Add a command 'lossage-size' to set the maximum number or recorded keystrokes (Bug#38796). * src/keyboard.c (lossage_limit): Static variable with the current lossage size limit. (MIN_NUM_RECENT_KEYS): Renamed from NUM_RECENT_KEYS. Set it as 100 and use it as the minimum value for lossage_limit. Keep the same default for the vector size as before (300). (lossage-size): New command. (update_recent_keys): Helper function. (command_loop_1) (record_char) (recent-keys) (syms_of_keyboard): Use lossage_limit as the vector size. * lisp/help.el (view-lossage): Mention the new command in the docstring. * etc/NEWS (Changes in Emacs 28.1): Announce this change. * doc/emacs/help.texi (Misc Help): Update manual. * test/src/keyboard-tests.el (keyboard-lossage-size): Add test. diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index 06ad5a583d..232b611f41 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -573,10 +573,13 @@ Misc Help @kindex C-h l @findex view-lossage +@findex lossage-size If something surprising happens, and you are not sure what you typed, use @kbd{C-h l} (@code{view-lossage}). @kbd{C-h l} displays your last -300 input keystrokes and the commands they invoked. If you see -commands that you are not familiar with, you can use @kbd{C-h k} or +input keystrokes and the commands they invoked. By default, Emacs +stores the last 300 keystrokes; if you wish, you can change this number with +the command @code{lossage-size}. +If you see commands that you are not familiar with, you can use @kbd{C-h k} or @kbd{C-h f} to find out what they do. @kindex C-h e diff --git a/etc/NEWS b/etc/NEWS index 8ff62b6dc0..6fd23422cf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -85,6 +85,10 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". * Changes in Emacs 28.1 ++++ +** The new command 'lossage-size' allow users to set the maximum +number of keystrokes and commands recorded. + +++ *** Emacs now defaults to UTF-8 instead of ISO-8859-1. This is only for the default, where the user has set no LANG (or diff --git a/lisp/help.el b/lisp/help.el index 729684af6b..edef78d207 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -458,6 +458,7 @@ view-lossage "Display last few input keystrokes and the commands run. For convenience this uses the same format as `edit-last-kbd-macro'. +See `lossage-size' to update the number of recorded keystrokes. To record all your input, use `open-dribble-file'." (interactive) diff --git a/src/keyboard.c b/src/keyboard.c index 590d183c4c..c0a41e6c4c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -103,7 +103,8 @@ Copyright (C) 1985-1989, 1993-1997, 1999-2020 Free Software Foundation, /* True in the single-kboard state, false in the any-kboard state. */ static bool single_kboard; -#define NUM_RECENT_KEYS (300) +/* Minimum allowed size of the recent_keys vector. */ +#define MIN_NUM_RECENT_KEYS (100) /* Index for storing next element into recent_keys. */ static int recent_keys_index; @@ -111,7 +112,10 @@ #define NUM_RECENT_KEYS (300) /* Total number of elements stored into recent_keys. */ static int total_keys; -/* This vector holds the last NUM_RECENT_KEYS keystrokes. */ +/* Size of the recent_keys vector. */ +static int lossage_limit = 3 * MIN_NUM_RECENT_KEYS; + +/* This vector holds the last lossage_limit keystrokes. */ static Lisp_Object recent_keys; /* Vector holding the key sequence that invoked the current command. @@ -1421,10 +1425,10 @@ command_loop_1 (void) /* Execute the command. */ { - total_keys += total_keys < NUM_RECENT_KEYS; + total_keys += total_keys < lossage_limit; ASET (recent_keys, recent_keys_index, Fcons (Qnil, cmd)); - if (++recent_keys_index >= NUM_RECENT_KEYS) + if (++recent_keys_index >= lossage_limit) recent_keys_index = 0; } Vthis_command = cmd; @@ -3248,15 +3252,15 @@ record_char (Lisp_Object c) int ix1, ix2, ix3; if ((ix1 = recent_keys_index - 1) < 0) - ix1 = NUM_RECENT_KEYS - 1; + ix1 = lossage_limit - 1; ev1 = AREF (recent_keys, ix1); if ((ix2 = ix1 - 1) < 0) - ix2 = NUM_RECENT_KEYS - 1; + ix2 = lossage_limit - 1; ev2 = AREF (recent_keys, ix2); if ((ix3 = ix2 - 1) < 0) - ix3 = NUM_RECENT_KEYS - 1; + ix3 = lossage_limit - 1; ev3 = AREF (recent_keys, ix3); if (EQ (XCAR (c), Qhelp_echo)) @@ -3307,12 +3311,12 @@ record_char (Lisp_Object c) { if (!recorded) { - total_keys += total_keys < NUM_RECENT_KEYS; + total_keys += total_keys < lossage_limit; ASET (recent_keys, recent_keys_index, /* Copy the event, in case it gets modified by side-effect by some remapping function (bug#30955). */ CONSP (c) ? Fcopy_sequence (c) : c); - if (++recent_keys_index >= NUM_RECENT_KEYS) + if (++recent_keys_index >= lossage_limit) recent_keys_index = 0; } else if (recorded < 0) @@ -3326,10 +3330,10 @@ record_char (Lisp_Object c) while (recorded++ < 0 && total_keys > 0) { - if (total_keys < NUM_RECENT_KEYS) + if (total_keys < lossage_limit) total_keys--; if (--recent_keys_index < 0) - recent_keys_index = NUM_RECENT_KEYS - 1; + recent_keys_index = lossage_limit - 1; ASET (recent_keys, recent_keys_index, Qnil); } } @@ -10410,6 +10414,62 @@ DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 1, 0, ? Qt : Qnil); } +/* Reallocate recent_keys copying the keystrokes in the right order */ +static void +update_recent_keys (int new_size, int kept_keys) +{ + int osize = ASIZE (recent_keys); + eassert (recent_keys_index < osize); + eassert (kept_keys <= min (osize, new_size)); + Lisp_Object v = make_nil_vector (new_size); + int i, idx; + for (i = 0; i < kept_keys; ++i) + { + idx = recent_keys_index - kept_keys + i; + while (idx < 0) + idx += osize; + ASET (v, i, AREF (recent_keys, idx)); + } + recent_keys = v; + total_keys = kept_keys; + recent_keys_index = total_keys % new_size; + lossage_limit = new_size; + +} + +DEFUN ("lossage-size", Flossage_size, Slossage_size, 0, 1, + "(list (read-number \"new-size: \" (lossage-size)))", + doc: /* Return the maximum number of saved keystrokes. +Called with ARG, then set this limit to ARG and return it. + +The saved keystrokes are the records shown by `view-lossage'. */) + (Lisp_Object arg) +{ + if (NILP(arg)) + return make_fixnum (lossage_limit); + + if (!FIXNATP (arg)) + user_error ("Value must be a positive integer"); + int osize = ASIZE (recent_keys); + eassert (lossage_limit == osize); + int min_size = MIN_NUM_RECENT_KEYS; + int new_size = XFIXNAT (arg); + + if (new_size == osize) + return make_fixnum (lossage_limit); + + if (new_size < min_size) + { + AUTO_STRING (fmt, "Value must be >= %d"); + Fsignal (Quser_error, list1 (CALLN (Fformat, fmt, make_fixnum (min_size)))); + } + + int kept_keys = new_size > osize ? total_keys : min (new_size, total_keys); + update_recent_keys (new_size, kept_keys); + + return make_fixnum (lossage_limit); +} + DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, doc: /* Return vector of last few events, not counting those from keyboard macros. If INCLUDE-CMDS is non-nil, include the commands that were run, @@ -10419,21 +10479,21 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, bool cmds = !NILP (include_cmds); if (!total_keys - || (cmds && total_keys < NUM_RECENT_KEYS)) + || (cmds && total_keys < lossage_limit)) return Fvector (total_keys, XVECTOR (recent_keys)->contents); else { Lisp_Object es = Qnil; - int i = (total_keys < NUM_RECENT_KEYS + int i = (total_keys < lossage_limit ? 0 : recent_keys_index); - eassert (recent_keys_index < NUM_RECENT_KEYS); + eassert (recent_keys_index < lossage_limit); do { Lisp_Object e = AREF (recent_keys, i); if (cmds || !CONSP (e) || !NILP (XCAR (e))) es = Fcons (e, es); - if (++i >= NUM_RECENT_KEYS) + if (++i >= lossage_limit) i = 0; } while (i != recent_keys_index); es = Fnreverse (es); @@ -11686,7 +11746,7 @@ syms_of_keyboard (void) staticpro (&modifier_symbols); } - recent_keys = make_nil_vector (NUM_RECENT_KEYS); + recent_keys = make_nil_vector (lossage_limit); staticpro (&recent_keys); this_command_keys = make_nil_vector (40); @@ -11736,6 +11796,7 @@ syms_of_keyboard (void) defsubr (&Srecursive_edit); defsubr (&Sinternal_track_mouse); defsubr (&Sinput_pending_p); + defsubr (&Slossage_size); defsubr (&Srecent_keys); defsubr (&Sthis_command_keys); defsubr (&Sthis_command_keys_vector); diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el index 1988ba51a7..970a53555f 100644 --- a/test/src/keyboard-tests.el +++ b/test/src/keyboard-tests.el @@ -32,5 +32,20 @@ keyboard-unread-command-events (read-event nil nil 2)) ?\C-b))) +(ert-deftest keyboard-lossage-size () + "Test `lossage-size'." + (let ((min-value 100) + (lossage-orig (lossage-size))) + (dolist (factor (list 1 3 4 5 10 7 3)) + (let ((new-lossage (* factor min-value))) + (should (= new-lossage (lossage-size new-lossage))))) + ;; Wrong type + (should-error (lossage-size -5)) + (should-error (lossage-size "200")) + ;; Less that minimum value + (should-error (lossage-size (1- min-value))) + (should (= lossage-orig (lossage-size lossage-orig))))) + + (provide 'keyboard-tests) ;;; keyboard-tests.el ends here --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 28.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.16.0) of 2020-09-12 built on localhost.example.com Repository revision: 4c3f3bf25623c936ca07249203147ae0332d64ed Repository branch: master From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 17 10:35:35 2020 Received: (at 38796) by debbugs.gnu.org; 17 Sep 2020 14:35:35 +0000 Received: from localhost ([127.0.0.1]:38531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kIv0Z-0000ZT-4z for submit@debbugs.gnu.org; Thu, 17 Sep 2020 10:35:35 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]:55711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kIv0U-0000Z9-0F; Thu, 17 Sep 2020 10:35:34 -0400 Received: by mail-wm1-f47.google.com with SMTP id d4so2197492wmd.5; Thu, 17 Sep 2020 07:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=B+Tk+ZacsLKkBY4hAU5w0Ba75BTLkRk7tyn2SN9khes=; b=Y05y/u+Ju0EKNFdneT2X+dA1kzj1GyUm+1A0mFVWeT2CKVlvTr0gzZsfGCerqLL8GM /FI4YLx9cSif/9BMkuC2CXvHK6cRvEmBiHMfIq5Xl89Fy7OSom1e4tShipuCFCrirUax 5mOz5ZUNsSgLpQZMke74hWyYit0V7baIWymH1338J3IaABameU+Ia7PohcZCgJ/aUyn9 9CVOifdJ1AFJ85BJ1gpHgOA7gH8jAalRksW8A5AzTm+SLIH2Vd2yqInKpPcmuu92S73/ VsTxSxkSkLNrYBsgEq5c5vWgo29Q6z4wi7kq6p9y111IJLz+zTm8T8N8ev6AsAV4W0r+ sTJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=B+Tk+ZacsLKkBY4hAU5w0Ba75BTLkRk7tyn2SN9khes=; b=eMmTTDUgM2vzrzv8FP6DeFCR6L8qA8gqDZIopqHbbzNBGCy2Gsd0MO23vH/QLO6fTB lSS7HwezWXcy/eTmmuKxR7Z7pua35yXJr5fTTi0o/mj3u1NZczouOkqr06zutfki3gEe iITr3Eo640UIjXYELDLDNAAi0pQBkkNJa40zgoBuSttuR3NJilD0yPgOQ4fhtsphi5nt bQD2YnE3vj6TqE/WL0kgpyhSFmhHtMIPHdF7XOf0UvEdB31ST7qqGG12qEonohD0ov4q prwLC4nnIRezNufsRztocXm8lFd2i56PFhmiIWwZdQkylCI0t44Svbcm07kDETsF2xU5 xTFg== X-Gm-Message-State: AOAM532hUfruMSL80bpHi1xadQ8wm/xxeE31uX6EKeIm2AZi+LnLbFmx lSInqS0S6YdZ9rr2x59R66w= X-Google-Smtp-Source: ABdhPJziZeESlmoo+tMzhhiZI/ADTDdXD4U1z19Y70lf9sgJOTMChTkYtfcGJbs2DHMXv/TcX01ddA== X-Received: by 2002:a7b:cf36:: with SMTP id m22mr10944613wmg.51.1600353323943; Thu, 17 Sep 2020 07:35:23 -0700 (PDT) Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id k4sm39471397wrx.51.2020.09.17.07.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 07:35:23 -0700 (PDT) From: Tino Calancha To: 38796-done@debbugs.gnu.org Subject: Re: bug#38796: 26.3; `view-lossage': Use a variable for the lossage limit References: <43aac56d-ecf1-44ed-9be1-ffb8e5f8a7ce@default> <83zhfbm448.fsf@gnu.org> <87zh8pij6e.fsf@calancha-pc.dy.bbexcite.jp> <83v9jc3o3q.fsf@gnu.org> <87wo3qj1s6.fsf@calancha-pc.dy.bbexcite.jp> <87eenygyrx.fsf@gnus.org> <87d03beq3g.fsf@gmail.com> <83zh6fz4q1.fsf@gnu.org> <87363xj3be.fsf@gmail.com> <83o8mlu4mh.fsf@gnu.org> <87blibdvpi.fsf@gmail.com> Date: Thu, 17 Sep 2020 16:35:22 +0200 In-Reply-To: <87blibdvpi.fsf@gmail.com> (Tino Calancha's message of "Sat, 12 Sep 2020 14:29:45 +0200") Message-ID: <87363gwjx1.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38796 Cc: larsi@gnus.org, stefankangas@gmail.com, monnier@iro.umontreal.ca, 38796@debbugs.gnu.org, uyennhi.qm@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Tino Calancha writes: > I am glad to push the following patch next week if there are no > complaints. Pushed into master branch as commit 'Give Lisp control on the lossage size' (23a3333b3ef0768f48f64f382ee899050b6103be) From unknown Fri Jun 13 11:32:54 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 16 Oct 2020 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator