From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bob Rogers Newsgroups: gmane.emacs.bugs Subject: bug#54133: 29.0.50; Buffer-menu-visit-tags-table disrupts non-tags buffers Date: Wed, 23 Feb 2022 16:37:11 -0500 Message-ID: <25110.43271.146078.920965@orion.rgrjr.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="rKtjf8ESkA" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39740"; mail-complaints-to="usenet@ciao.gmane.io" To: 54133@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 23 22:38:15 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMzKw-000A6c-Sk for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Feb 2022 22:38:15 +0100 Original-Received: from localhost ([::1]:34826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMzKv-0003Ko-De for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Feb 2022 16:38:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMzKk-0003J9-8b for bug-gnu-emacs@gnu.org; Wed, 23 Feb 2022 16:38:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nMzKj-00015v-Vh for bug-gnu-emacs@gnu.org; Wed, 23 Feb 2022 16:38:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nMzKj-0007DO-Tt for bug-gnu-emacs@gnu.org; Wed, 23 Feb 2022 16:38:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Bob Rogers Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 23 Feb 2022 21:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54133 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.164565223827677 (code B ref -1); Wed, 23 Feb 2022 21:38:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Feb 2022 21:37:18 +0000 Original-Received: from localhost ([127.0.0.1]:46726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nMzK2-0007CL-84 for submit@debbugs.gnu.org; Wed, 23 Feb 2022 16:37:18 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:53194) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nMzK0-0007CC-8h for submit@debbugs.gnu.org; Wed, 23 Feb 2022 16:37:16 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMzK0-00035T-3B for bug-gnu-emacs@gnu.org; Wed, 23 Feb 2022 16:37:16 -0500 Original-Received: from [2607:f8b0:4864:20::72b] (port=36481 helo=mail-qk1-x72b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nMzJy-00011a-2U for bug-gnu-emacs@gnu.org; Wed, 23 Feb 2022 16:37:15 -0500 Original-Received: by mail-qk1-x72b.google.com with SMTP id g24so243825qkl.3 for ; Wed, 23 Feb 2022 13:37:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rgrjr-com.20210112.gappssmtp.com; s=20210112; h=from:mime-version:content-transfer-encoding:message-id:date:to :subject; bh=1VFQ61LWoKI+zmWTC+i5ePp+uttCVwA0t65Y1SfnAe0=; b=yNZNGQBYIFP1m+p6juBp/DDNgSBc+L7TgGGj+BRMTTqxQ9x4c0ru80obZeJ/Cc6Z70 8TfDDPUPD11Nkp/qoy+izqdlOSAgJtYEHdzaf8/VSUcRBd0RVt9o7lGwQPX8zRLK2c2t JKjnAqTIRsjUd5BHyQCl4IrMHNYXs2L+I7FqgQUkxQaN79YeuEFEcJJ2l80R04C55ZMs p62N05PlKQBgzcWCeRHrWfSbn7kJOpKPS6xpSrbss9cLa4o8A4ttnqNSN/KDCWLb8H15 FAS0xtQtnv9mvc/31j+gSBW54/B/SEdNCQfYfk7jdXjeDaaVgGk6vRHjGOVTN8UtCpmr SSiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:content-transfer-encoding :message-id:date:to:subject; bh=1VFQ61LWoKI+zmWTC+i5ePp+uttCVwA0t65Y1SfnAe0=; b=0VHYyTD6qvcUyT5lpBMhJnD0ZdNd9KOJ+/pIyCTogs8Qy9bwyo92lxofjnI7c92XAl wLHrMas3M4WkMrmWG3USxHvdAwibFE/uoau3oPH560JWSQPAKXGGEPFNtDuFJljZEa5e jbkN4un3R7GbkDEa4yQLyOGoWW2Go5G5+CeFHschf5UAF0FsdOYgJPhGjgiYAIHtrHgQ IL5D05S44oAHh4A2+8RwsDm98E+6neAXDyMYJplj6dKvny0qxh8bp6/jeCY38WPo6Vr4 VBMwQ8nEDfU3xe+3VsTrAyWZqQTdm2l+1gSIWAFtUQrQ9b7O/rRM16qw0o/jwEcIY5L3 NQIg== X-Gm-Message-State: AOAM530H3xwu13mVALtZutYrldgK83Nglb81Vl9e33yaUTGpa82cFgcu 4IK+23N5F6DMBEo7EI2SuZx9iIp5IFzFqRpx X-Google-Smtp-Source: ABdhPJz3kp60cjt1uvaoaShyce2tOU4dWOLri9F4a1bYAGsipyOIv7Mlbdo1ABUzYB+OCewSW0L29Q== X-Received: by 2002:a05:620a:48d:b0:47e:17f5:a33f with SMTP id 13-20020a05620a048d00b0047e17f5a33fmr1155998qkr.727.1645652232837; Wed, 23 Feb 2022 13:37:12 -0800 (PST) Original-Received: from orion.rgrjr.com ([2601:19c:4600:3270::c]) by smtp.gmail.com with ESMTPSA id k5sm357947qkk.82.2022.02.23.13.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 13:37:12 -0800 (PST) X-Mailer: VM 7.19 under Emacs 29.0.50 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72b (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::72b; envelope-from=rogers@rgrjr.com; helo=mail-qk1-x72b.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:227544 Archived-At: --rKtjf8ESkA Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2022-02-19 built on orion Repository revision: 563bb08c5998f82e034a0aa1b48dce29fb9bc375 Repository branch: rgr-smtpmail-env-from Windowing system distributor 'The X.Org Foundation', version 11.0.12003000 System Description: openSUSE Leap 15.3 Configured using: 'configure --with-dbus=no --with-gsettings=no --with-gif=ifavailable --with-tiff=no --with-gnutls=yes --with-gconf=no' Configured features: ACL CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB To reproduce: In master ecaedf2117cb015ad4028e4d6fc7058608c98096: 1. "emacs -Q &" 2. Visit pretty much any random file that is NOT a tags file; for this purpose, lisp/abbrev.el from the source tree will do nicely. 3. Type "C-x C-b" to get the "*Buffer List*" window to appear. 4. Type "C-x o" to move the to the buffer list, then move to the abbrev.el line, and type "t" to invoke Buffer-menu-visit-tags-table on it (which I seem to do accidentally more often than I care to admit). This produces the error message: user-error: File /scratch/rogers/emacs/lisp/abbrev.el is not a valid tags table but the abbrev.el buffer is left in tags-table-mode, and any undo information is thrown away. The attached patch addresses the problem in a straightforward way by making Buffer-menu-visit-tags-table prompt the user for buffers not already in tags-table-mode. The real problem is that visit-tags-table assumes that the user knows what they're doing, and makes these irreversible changes before being sure of having a valid tags table. That would be a harder thing to fix, though -- and might not deal as well with my buffer-menu typos. ;-} -- Bob Rogers http://www.rgrjr.com/ --rKtjf8ESkA Content-Type: text/x-patch Content-Description: Content-Disposition: inline; filename="0001-Make-Buffer-menu-visit-tags-table-more-circumspect.patch" Content-Transfer-Encoding: quoted-printable =46rom 05d2d1855cddc8d5c310d718c07d91ae861b8436 Mon Sep 17 00:00:00 2001 From: Bob Rogers Date: Wed, 23 Feb 2022 16:23:17 -0500 Subject: [PATCH] Make Buffer-menu-visit-tags-table more circumspect * lisp/buff-menu.el: + (Buffer-menu-visit-tags-table): Ask before visit-tags-table on a buffer not already in tags-table-mode, lest it destroy state. --- lisp/buff-menu.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index 50c2c155ca..0bed539008 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -530,10 +530,21 @@ Buffer-menu-multi-occur (defun Buffer-menu-visit-tags-table () "Visit the tags table in the buffer on this line. See `visit-tags-t= able'." (interactive nil Buffer-menu-mode) - (let ((file (buffer-file-name (Buffer-menu-buffer t)))) - (if file -=09(visit-tags-table file) - (error "Specified buffer has no file")))) + (let* ((buffer (Buffer-menu-buffer t)) + (file (buffer-file-name buffer))) + (or file + (error "Specified buffer has no file")) + ;; Ensure that it's really a tags file buffer (or the user at + ;; least believes it should be). Otherwise, visit-tags-table will= + ;; change the mode and discard any undo information. + (if (not (or (eq (with-current-buffer buffer + major-mode) + 'tags-table-mode) + (yes-or-no-p + (format "%s is not a tags table; visit as such anywa= y=3F " + buffer)))) + (error "Aborted.")) + (visit-tags-table file))) =20 (defun Buffer-menu-1-window () "Select this line's buffer, alone, in full frame." --=20 2.34.1 --rKtjf8ESkA--