From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#46268: 27.1.91; Error in occur-rename-buffer Date: Wed, 03 Feb 2021 10:54:24 +0200 Organization: LINKOV.NET Message-ID: <874kitttd3.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25382"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: stefan monnier To: 46268@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 03 10:43:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7Egq-0006Vv-SN for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 10:43:12 +0100 Original-Received: from localhost ([::1]:35532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Egp-0008GS-2V for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 04:43:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7Efi-0007si-AZ for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 04:42:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7Efi-0003xj-3F for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 04:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7Efh-0005RB-W7; Wed, 03 Feb 2021 04:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Feb 2021 09:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46268 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: stefan monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.161234530420872 (code B ref -1); Wed, 03 Feb 2021 09:42:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Feb 2021 09:41:44 +0000 Original-Received: from localhost ([127.0.0.1]:36834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7EfP-0005QU-Ft for submit@debbugs.gnu.org; Wed, 03 Feb 2021 04:41:43 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:56574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7EfM-0005QF-HG for submit@debbugs.gnu.org; Wed, 03 Feb 2021 04:41:42 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7EfM-0007hM-A0 for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 04:41:40 -0500 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:47933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7EfF-0003eo-Fi for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 04:41:40 -0500 Original-Received: from mail.gandi.net (m91-129-108-204.cust.tele2.ee [91.129.108.204]) (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 326EA200008 for ; Wed, 3 Feb 2021 09:41:28 +0000 (UTC) Received-SPF: pass client-ip=217.70.178.232; envelope-from=juri@linkov.net; helo=relay12.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:199183 Archived-At: --=-=-= Content-Type: text/plain Tags: patch X-Debbugs-Cc: Stefan Monnier After evaluating (add-hook 'occur-hook 'occur-rename-buffer) then selecting a region, and running 'M-x occur' with any string in the active region, signals the error: (wrong-type-argument bufferp #) It seems the attached patch is the right way to fix this. Also Cc:ing Stefan with a question about occur--garbage-collect-revert-args: trying to revert the Occur buffer created from an active region removes the source buffer name from the Occur buffer name. For example, (after applying the attached patch) 'M-x occur' on the active region in *scratch* creates the buffer *Occur: *scratch**. But reverting the Occur buffer with 'g' removes the *scratch* buffer name, and renames the Occur buffer to *Occur: *. This is because of two lines in occur-1: (occur--garbage-collect-revert-args) (setq occur-revert-arguments (list regexp nlines bufs)) where occur--garbage-collect-revert-args deletes the overlay with the buffer name *scratch*, and later occur-rename-buffer can't get the original buffer name from occur-revert-arguments. And I don't know how to fix this. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=occur-rename-buffer-overlay.patch diff --git a/lisp/replace.el b/lisp/replace.el index f13d27aff8..c4c80118b4 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -1544,11 +1544,17 @@ occur-rename-buffer (interactive "P\np") (with-current-buffer (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*")) - (rename-buffer (concat "*Occur: " - (mapconcat #'buffer-name - (car (cddr occur-revert-arguments)) "/") - "*") - (or unique-p (not interactive-p))))) + (rename-buffer + (concat "*Occur: " + (mapconcat (lambda (boo) + (or (and (buffer-live-p boo) + (buffer-name boo)) + (and (overlayp boo) + (buffer-live-p (overlay-buffer boo)) + (buffer-name (overlay-buffer boo))))) + (car (cddr occur-revert-arguments)) "/") + "*") + (or unique-p (not interactive-p))))) ;; Region limits when `occur' applies on a region. (defvar occur--final-pos nil) --=-=-=--