From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steve Yegge Newsgroups: gmane.emacs.devel Subject: hook for buffers becoming writable/read-only Date: Tue, 21 Jul 2009 20:39:42 -0700 Message-ID: <9c768dc60907212039k5025c1adq583f00898e18cf82@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016364ee1e4226c1d046f431f6b X-Trace: ger.gmane.org 1248284192 8776 80.91.229.12 (22 Jul 2009 17:36:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Jul 2009 17:36:32 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 22 19:36:26 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MTfjt-0001FK-K0 for ged-emacs-devel@m.gmane.org; Wed, 22 Jul 2009 19:36:26 +0200 Original-Received: from localhost ([127.0.0.1]:58658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTfjt-0005dQ-0J for ged-emacs-devel@m.gmane.org; Wed, 22 Jul 2009 13:36:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MTSgO-0001ZP-Vi for emacs-devel@gnu.org; Tue, 21 Jul 2009 23:39:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MTSgK-0001Xw-4J for emacs-devel@gnu.org; Tue, 21 Jul 2009 23:39:56 -0400 Original-Received: from [199.232.76.173] (port=47568 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTSgJ-0001Xq-UN for emacs-devel@gnu.org; Tue, 21 Jul 2009 23:39:51 -0400 Original-Received: from smtp-out.google.com ([216.239.45.13]:31606) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MTSgJ-0005JT-Cv for emacs-devel@gnu.org; Tue, 21 Jul 2009 23:39:51 -0400 Original-Received: from spaceape9.eur.corp.google.com (spaceape9.eur.corp.google.com [172.28.16.143]) by smtp-out.google.com with ESMTP id n6M3djnj029079 for ; Tue, 21 Jul 2009 20:39:46 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1248233986; bh=M30BSqd1XMl17fH2vbayhwumAUw=; h=DomainKey-Signature:MIME-Version:Date:Message-ID:Subject:From:To: Content-Type:X-System-Of-Record; b=Tw1goFns+GOKJCP6RfEvWN6LOcAt+U0 FGAgfuLzs1kST9PQdnc8Qj2c99zoVuvJs5hkRBeDU6rB/MAsOlPPsrw== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:date:message-id:subject:from:to:content-type:x-system-of-record; b=A2S5LLmkp5buTBFYE66633iKNOYtSkVTH1nhy+HrSLstkgK3eqoK+pLFXyTzOVju/ iizl/lNnN18gIs93eCeyA== Original-Received: from yxe4 (yxe4.prod.google.com [10.190.2.4]) by spaceape9.eur.corp.google.com with ESMTP id n6M3dgu0028614 for ; Tue, 21 Jul 2009 20:39:43 -0700 Original-Received: by yxe4 with SMTP id 4so997193yxe.31 for ; Tue, 21 Jul 2009 20:39:42 -0700 (PDT) Original-Received: by 10.90.69.15 with SMTP id r15mr389889aga.4.1248233982683; Tue, 21 Jul 2009 20:39:42 -0700 (PDT) X-System-Of-Record: true X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Wed, 22 Jul 2009 13:35:22 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:113009 Archived-At: --0016364ee1e4226c1d046f431f6b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I have a minor mode that wishes to disable itself when the bufferbecomes writable, but I do not see a way to do it. The closest existing scenario I can see is view-mode, but view-mode is special-cased in toggle-read-only, rather than listening on a hook. This does not seem clean. Moreover, most modes do not use toggle-read-only; they set the buffer-read-only variable directly. This has the (in my mind) unwanted side-effect of leaving a writable buffer in view-mode if it is made writable by setting the variable directly. The semantics are admittedly a bit vague with respect to temporary changes from let-binding buffer-read-only or inhibit-read-only, but I would be satisfied if the hook were run on any persistent change to the buffer-read-only variable. Perhaps rather than creating a new hook, we could simply call the before-change-functions and after-change-functions when the buffer read-only status changes. -steve --0016364ee1e4226c1d046f431f6b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I have a minor mode that wishes to disable itself when the buffer
becom= es writable, but I do not see a way to do it.

The closes= t existing scenario I can see is view-mode, but view-mode
is spec= ial-cased in toggle-read-only, rather than listening on a hook.
This=A0does=A0not=A0seem=A0clean.

Moreover, m= ost modes do not use toggle-read-only; they set the
buffer-read-o= nly variable directly.=A0=A0This=A0has=A0the=A0(in=A0my=A0mind)=A0unwanted<= /div>
side-effect=A0of=A0leaving=A0a=A0writable=A0buffer=A0in=A0view-mo= de=A0if=A0it=A0is=A0made
writable=A0by=A0setting=A0the=A0variable=A0directly.

The semantics are admittedly a bit vague with respect to temporary<= /div>
changes from let-binding buffer-read-only or inhibit-read-only, b= ut
I would be satisfied if the hook were run on any persistent change
to the buffer-read-only variable.

Perhaps r= ather than creating a new hook, we could simply call the
before-c= hange-functions and after-change-functions when the buffer
read-only status changes.

-steve
--0016364ee1e4226c1d046f431f6b--