From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jiege Chen Newsgroups: gmane.emacs.bugs Subject: bug#23777: 25.0.95; Throwing (error "Selecting deleted buffer") in timer Date: Sat, 18 Jun 2016 08:09:21 +0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (1.0) Content-Type: multipart/alternative; boundary=Apple-Mail-67CDBFE6-4031-4F92-878A-D30E003247EF Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1466216608 675 80.91.229.3 (18 Jun 2016 02:23:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Jun 2016 02:23:28 +0000 (UTC) To: 23777@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 18 04:23:18 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bE5uo-0000cz-47 for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Jun 2016 04:23:18 +0200 Original-Received: from localhost ([::1]:32781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bE5uk-0004eu-1a for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Jun 2016 22:23:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bE5uc-0004ae-I4 for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 22:23:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bE5uY-0002Tq-Cx for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 22:23:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bE5uX-0002Tm-TU for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 22:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bE5uX-00009d-Ms for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 22:23:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Jiege Chen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Jun 2016 02:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23777 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 23777-submit@debbugs.gnu.org id=B23777.1466216573577 (code B ref 23777); Sat, 18 Jun 2016 02:23:01 +0000 Original-Received: (at 23777) by debbugs.gnu.org; 18 Jun 2016 02:22:53 +0000 Original-Received: from localhost ([127.0.0.1]:44650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bE5uP-00009E-0d for submit@debbugs.gnu.org; Fri, 17 Jun 2016 22:22:53 -0400 Original-Received: from smtpbgsg2.qq.com ([54.254.200.128]:45616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bE5uI-00008r-3F for 23777@debbugs.gnu.org; Fri, 17 Jun 2016 22:22:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1466216553; bh=NqM0bGhgxB8Lcxr6akQ2r2LM0B0mY4I/7Io7wP+O8yM=; h=Content-Type:Content-Transfer-Encoding:From:Mime-Version:Subject:Message-Id:Date:References:To; b=Ps9HuNMAjFI4xtQFvjY7B+Dv3PhFAXM1wo6e+goSVhK3TWX4yZDT5icMteh7mjSjp XXnL/oua+4BdknmI1+7sIBoOWlGQAh/eL5iExYoDs6dmuz5xc5O23Sruw0OvBvXdIL wuhAENyVy9ddds0TpIE0oh5H/OWupCNQeXs9KZr8= X-QQ-mid: esmtp31t1466216551t957t26811 Original-Received: from [172.20.10.4] (unknown [117.136.79.133]) by esmtp4.qq.com (ESMTP) with SMTP id 0 for <23777@debbugs.gnu.org>; Sat, 18 Jun 2016 10:21:27 +0800 (CST) X-QQ-SSF: 0100000000000050F31300000000000 X-QQ-FEAT: WQGUhO9RX++YvhMhrfRLkymtuYKLNvR51H29n8m3V+dGxyQBAfWiP2dau0ATX ivkEc9nK15b9d9oZV1V6pO9GG0yywkw28zd6h3NEHSvo0AQg4Ic3ZHhwqb9dQC6j3wD3/kB lX26XiH8FpF9qUyGNDVio2xM5fQ889k+PVf4PbRs1gbZVeGvqhFUG8qjFBlu+fI0K9YNuP/ AWtAEKpulU+FqlZfA1OzcZlmKQsjfVBEfk/RVXO71SBKIg9DY0b8huhVdlKAyu3AsGNz6l4 jgTdSX/YrXJXJM X-QQ-GoodBg: 0 X-Mailer: iPad Mail (13F69) X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:119708 Archived-At: --Apple-Mail-67CDBFE6-4031-4F92-878A-D30E003247EF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Forward to the mailing list. Sent from my iPad Begin forwarded message: > From: Jiajie Chen > Date: June 17, 2016 at 7:27:52 PM GMT+8 > To: Noam Postavsky > Subject: Re: bug#23777: 25.0.95; Throwing (error "Selecting deleted buffer= ") in timer >=20 >=20 > Thanks. That works. This behaviour is only observed in Emacs daemon. >=20 > This is what I have found: >=20 > The backtrace: > Debugger entered--Lisp error: (error "Selecting deleted buffer") > set-buffer(#) > (save-current-buffer (set-buffer buf) (let* ((modified (buffer-modified-p= )) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)= ) (unwind-protect (progn (remove-text-properties (point-min) (point-max) (qu= ote (fontified)))) (if modified nil (restore-buffer-modified-p nil))))) > (closure (t) (buf) (save-current-buffer (set-buffer buf) (let* ((modified= (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-mo= dification-hooks t)) (unwind-protect (progn (remove-text-properties (point-m= in) (point-max) (quote (fontified)))) (if modified nil (restore-buffer-modif= ied-p nil))))))(#) > apply((closure (t) (buf) (save-current-buffer (set-buffer buf) (let* ((mo= dified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhi= bit-modification-hooks t)) (unwind-protect (progn (remove-text-properties (p= oint-min) (point-max) (quote (fontified)))) (if modified nil (restore-buffer= -modified-p nil)))))) #) > timer-event-handler([t 22371 54023 394400 nil (closure (t) (buf) (save-cu= rrent-buffer (set-buffer buf) (let* ((modified (buffer-modified-p)) (buffer-= undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-p= rotect (progn (remove-text-properties (point-min) (point-max) (quote ...))) (= if modified nil (restore-buffer-modified-p nil)))))) (#) nil 0= ]) >=20 >=20 > Then I ran `ag 'modified > \(buffer-modified-p\).*\n.*buffer-undo.*\n*inhib'` and got this: > dtrt-indent-20160523.1318/dtrt-indent-diag.el:163: `((,= modified (buffer-modified-p)) > dtrt-indent-20160523.1318/dtrt-indent-diag.el:164: (b= uffer-undo-list t) > dtrt-indent-20160523.1318/dtrt-indent-diag.el:165: (i= nhibit-read-only t) > markdown-mode-20160610.1745/markdown-mode.el:6321: (let* ((modified (buff= er-modified-p)) > markdown-mode-20160610.1745/markdown-mode.el:6322: (buffer-undo-li= st t) > markdown-mode-20160610.1745/markdown-mode.el:6323: (inhibit-read-o= nly t) >=20 > Then reading the code in those files, the code turned out to be in a macro= : >=20 > (defmacro save-buffer-state (varlist &rest body) > "Bind variables according to VARLIST and eval BODY restoring buffer state= ." > (declare (indent 1) (debug let)) > (let ((modified (make-symbol "modified"))) > `(let* ,(append varlist > `((,modified (buffer-modified-p)) > (buffer-undo-list t) > (inhibit-read-only t) > (inhibit-point-motion-hooks t) > (inhibit-modification-hooks t) > deactivate-mark > buffer-file-name > buffer-file-truename)) > (progn > ,@body) > (unless ,modified > (restore-buffer-modified-p nil))))) >=20 >=20 > But I have found only one occurrence in dtrt-indent: >=20 > (defun dtrt-indent-highlight () > "Highlight non-excluded indentation in the current buffer." > (interactive) > (let ((language-and-variable > (cdr (dtrt-indent--search-hook-mapping major-mode)))) > (if (null language-and-variable) > (message "Major mode %s not supported by dtrt-indent" major-mode) > (save-buffer-state nil > (dtrt-indent--for-each-indentation > (car language-and-variable) > (lambda (histogram) > (put-text-property (save-excursion (beginning-of-line) (point)) > (point) > 'face '(background-color . "red")) > t) > nil))))) >=20 > Dunno how it is related to that timer execution. But according to the > comment above `save-buffer-state`, there might be a similar macro in > font-lock.el. Yes there is. > I did a grep in emacs source and found lots of them. Then I look at the > body part of that macro expansion: `(unwind-protect (progn > (remove-text-properties (point-min) (point-max) 'fontified)))`. However > I failed to find any occurrence. It might be another macro expansion > here. So I decide to put it aside and will investigate later. >=20 > Best regards, > Jiege CHen --Apple-Mail-67CDBFE6-4031-4F92-878A-D30E003247EF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Forward to the mailing list.
=


Sent from my iPad

Begin forwarded message:
From: Jiajie Chen <jiegec@qq.com>
Date: June 17, 2016 a= t 7:27:52 PM GMT+8
To: Noam Postavsky <npostavs@users.sourceforge.net>
Subje= ct: Re: bug#23777: 25.0.95; Throwing (error "Selecting deleted buffer= ") in timer


Thanks. That works. This behaviour is only observed in E= macs daemon.

This is what I have found:


The backtrace:
Debugger entere= d--Lisp error: (error "Selecting deleted buffer")
 set= -buffer(#<killed buffer>)
 (save-current-buffer (= set-buffer buf) (let* ((modified (buffer-modified-p)) (buffer-undo-list t) (= inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-protect (progn (= remove-text-properties (point-min) (point-max) (quote (fontified)))) (if mod= ified nil (restore-buffer-modified-p nil)))))
 (closur= e (t) (buf) (save-current-buffer (set-buffer buf) (let* ((modified (buffer-m= odified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification= -hooks t)) (unwind-protect (progn (remove-text-properties (point-min) (point= -max) (quote (fontified)))) (if modified nil (restore-buffer-modified-p nil)= )))))(#<killed buffer>)
 apply((closure (t) (buf= ) (save-current-buffer (set-buffer buf) (let* ((modified (buffer-modified-p)= ) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t))= (unwind-protect (progn (remove-text-properties (point-min) (point-max) (quo= te (fontified)))) (if modified nil (restore-buffer-modified-p nil)))))) #<= ;killed buffer>)
 timer-event-handler([t 22371 5402= 3 394400 nil (closure (t) (buf) (save-current-buffer (set-buffer buf) (let* (= (modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (i= nhibit-modification-hooks t)) (unwind-protect (progn (remove-text-properties= (point-min) (point-max) (quote ...))) (if modified nil (restore-buffer-modi= fied-p nil)))))) (#<killed buffer>) nil 0])

Then I ran `ag 'modified
\(buffer-mo= dified-p\).*\n.*buffer-undo.*\n*inhib'` and got this:
dtrt-i= ndent-20160523.1318/dtrt-indent-diag.el:163:      &= nbsp;            = ; `((,modified (buffer-modified-p))
dtrt-indent-2016052= 3.1318/dtrt-indent-diag.el:164:        &n= bsp;            =  (buffer-undo-list t)
dtrt-indent-20160523.1318/dtrt-in= dent-diag.el:165:          &nbs= p;           (inhibit= -read-only t)
markdown-mode-20160610.1745/markdown-mode.el:6= 321:  (let* ((modified (buffer-modified-p))
markdown-mo= de-20160610.1745/markdown-mode.el:6322:       =   (buffer-undo-list t)
markdown-mode-20160610.1745= /markdown-mode.el:6323:         (inh= ibit-read-only t)

Then reading the code in t= hose files, the code turned out to be in a macro:
(defmacro save-buffer-state (varlist &rest body)
=  "Bind variables according to VARLIST and eval BODY restoring buffer s= tate."
 (declare (indent 1) (debug let))
 (let ((modified (make-symbol "modified")))
 =   `(let* ,(append varlist
    = ;            &nb= sp;  `((,modified (buffer-modified-p))
 &nbs= p;            &n= bsp;      (buffer-undo-list t)
            &n= bsp;        (inhibit-read-only t)
          &= nbsp;          (inhibit-po= int-motion-hooks t)
      &nb= sp;            &= nbsp; (inhibit-modification-hooks t)
   = ;            &nb= sp;     deactivate-mark
 &nbs= p;            &n= bsp;      buffer-file-name
&n= bsp;            =         buffer-file-truename))

      (progn
&nbs= p;       ,@body)
 &= nbsp;    (unless ,modified
  =       (restore-buffer-modified-p nil)))))


But I have found only one occu= rrence in dtrt-indent:

(defun dtrt-indent-h= ighlight ()
 "Highlight non-excluded indentation in th= e current buffer."
 (interactive)
&nb= sp;(let ((language-and-variable
    &nb= sp;   (cdr (dtrt-indent--search-hook-mapping major-mode))))
   (if (null language-and-variable)        (message "Major mode %s no= t supported by dtrt-indent" major-mode)
   &= nbsp; (save-buffer-state nil
    &= nbsp;  (dtrt-indent--for-each-indentation
 &= nbsp;      (car language-and-variable)<= br>         (lambda (histogram= )
         &nb= sp;(put-text-property (save-excursion (beginning-of-line) (point))            &n= bsp;            =      (point)
   &nb= sp;            &= nbsp;            = ;'face '(background-color . "red"))
    = ;      t)
   &= nbsp;    nil)))))

Dunno= how it is related to that timer execution. But according to the
<= span>comment above `save-buffer-state`, there might be a similar macro in
font-lock.el. Yes there is.
I did a grep in em= acs source and found lots of them. Then I look at the
body p= art of that macro expansion: `(unwind-protect (progn
(remove= -text-properties (point-min) (point-max) 'fontified)))`. However
<= span>I failed to find any occurrence. It might be another macro expansion
here. So I decide to put it aside and will investigate later.<= /span>

Best regards,
Jiege CHen
= --Apple-Mail-67CDBFE6-4031-4F92-878A-D30E003247EF--