From unknown Sun Jun 22 04:28:18 2025 X-Loop: help-debbugs@gnu.org Subject: bug#5980: iimage.el and modification hooks Resent-From: Martin Pohlack Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Apr 2010 07:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 5980 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 5980@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.12717496858746 (code B ref -1); Tue, 20 Apr 2010 07:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 20 Apr 2010 07:48:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O48Bh-0002H1-7v for submit@debbugs.gnu.org; Tue, 20 Apr 2010 03:48:05 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O486Z-0002EY-BV for submit@debbugs.gnu.org; Tue, 20 Apr 2010 03:42:48 -0400 Received: from lists.gnu.org ([199.232.76.165]:49961) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O486W-00013m-6W for submit@debbugs.gnu.org; Tue, 20 Apr 2010 03:42:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O486V-0007hH-UD for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:42:43 -0400 Received: from [140.186.70.92] (port=60889 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O486D-0007fW-75 for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:42:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O485o-0004gn-Ol for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:42:24 -0400 Received: from os.inf.tu-dresden.de ([141.76.48.99]:40301) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O485i-0004eI-4I for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:41:57 -0400 Received: from [217.9.48.20] (helo=[165.204.15.163]) by os.inf.tu-dresden.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.71) id 1O485f-0006ni-JO for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 09:41:51 +0200 Message-ID: <4BCD5ABF.6010601@os.inf.tu-dresden.de> Date: Tue, 20 Apr 2010 09:41:51 +0200 From: Martin Pohlack User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9pre) Gecko/20100217 Shredder/3.0.3pre MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070304070002010503080807" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.0 (----) X-Mailman-Approved-At: Tue, 20 Apr 2010 03:48:03 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) This is a multi-part message in MIME format. --------------070304070002010503080807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I started to use iimage.el yesterday and like it. However, it still seems possible to *blindly* modify contents inside the display blocks which is confusing. Furthermore, if the regexp defining the block is destroyed that way, disabling iimage-mode does not remove the display block --- it will be stuck forever. I therefore use a modification hook for removing the display block in case the underlying text is modified. Please find the patch attached, in case you like it. Cheers, Martin Pohlack --------------070304070002010503080807 Content-Type: text/x-patch; name="iimage_modification-hooks.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="iimage_modification-hooks.diff" --- /home/mp26/src/emacs/lisp/iimage.el 2009-11-21 12:03:13.000000000 +0100 +++ iimage.el 2010-04-18 23:24:10.000000000 +0200 @@ -109,6 +109,19 @@ (defalias 'iimage-locate-file 'locate-file) +(defun iimage-modification-hook (beg end) + "Remove display property if a display region is modified." + ;;(debug-print "ii1 begin %d, end %d\n" beg end) + (let ((inhibit-modification-hooks t) + (beg (previous-single-property-change end 'display + nil (line-beginning-position))) + (end (next-single-property-change beg 'display + nil (line-end-position)))) + (when (and beg end (plist-get (text-properties-at beg) 'display)) + ;;(debug-print "ii2 begin %d, end %d\n" beg end) + (remove-text-properties beg end + '(display nil modification-hooks nil))))) + (defun iimage-mode-buffer (arg) "Display/undisplay images. With numeric ARG, display the images if and only if ARG is positive." @@ -128,9 +141,12 @@ iimage-mode-image-search-path)))) (if ing (add-text-properties (match-beginning 0) (match-end 0) - (list 'display (create-image file))) - (remove-text-properties (match-beginning 0) (match-end 0) - '(display))))))) + (list 'display (create-image file) + 'modification-hooks + (list 'iimage-modification-hook))) + (remove-list-of-text-properties + (match-beginning 0) (match-end 0) + '(display modification-hooks))))))) (set-buffer-modified-p modp))) ;;;###autoload --------------070304070002010503080807-- From unknown Sun Jun 22 04:28:18 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Martin Pohlack Subject: bug#5980: closed (Re: bug#5980: iimage.el and modification hooks) Message-ID: References: <4BCD5ABF.6010601@os.inf.tu-dresden.de> X-Gnu-PR-Message: they-closed 5980 X-Gnu-PR-Package: emacs Reply-To: 5980@debbugs.gnu.org Date: Mon, 07 Jun 2010 21:07:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1275944822-11711-1" This is a multi-part message in MIME format... ------------=_1275944822-11711-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #5980: iimage.el and modification hooks which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 5980@debbugs.gnu.org. --=20 5980: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D5980 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1275944822-11711-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 5980-done) by debbugs.gnu.org; 7 Jun 2010 21:06:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLjWG-00032c-RJ for submit@debbugs.gnu.org; Mon, 07 Jun 2010 17:06:05 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLjU0-000311-PF for 5980-done@debbugs.gnu.org; Mon, 07 Jun 2010 17:03:45 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEACf7DExFpYBi/2dsb2JhbACeHnLAV4UXBIxn X-IronPort-AV: E=Sophos;i="4.53,380,1272859200"; d="scan'208";a="67542760" Received: from 69-165-128-98.dsl.teksavvy.com (HELO pastel.home) ([69.165.128.98]) by ironport2-out.pppoe.ca with ESMTP; 07 Jun 2010 17:03:40 -0400 Received: by pastel.home (Postfix, from userid 20848) id 1E0A08175; Mon, 7 Jun 2010 17:03:40 -0400 (EDT) From: Stefan Monnier To: Martin Pohlack Subject: Re: bug#5980: iimage.el and modification hooks Message-ID: References: <4BCD5ABF.6010601@os.inf.tu-dresden.de> Date: Mon, 07 Jun 2010 17:03:40 -0400 In-Reply-To: <4BCD5ABF.6010601@os.inf.tu-dresden.de> (Martin Pohlack's message of "Tue, 20 Apr 2010 09:41:51 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5980-done X-Mailman-Approved-At: Mon, 07 Jun 2010 17:06:03 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > I started to use iimage.el yesterday and like it. However, it still > seems possible to *blindly* modify contents inside the display blocks > which is confusing. Furthermore, if the regexp defining the block is > destroyed that way, disabling iimage-mode does not remove the display > block --- it will be stuck forever. Installed, thank you, Stefan ------------=_1275944822-11711-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 20 Apr 2010 07:48:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O48Bh-0002H1-7v for submit@debbugs.gnu.org; Tue, 20 Apr 2010 03:48:05 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O486Z-0002EY-BV for submit@debbugs.gnu.org; Tue, 20 Apr 2010 03:42:48 -0400 Received: from lists.gnu.org ([199.232.76.165]:49961) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O486W-00013m-6W for submit@debbugs.gnu.org; Tue, 20 Apr 2010 03:42:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O486V-0007hH-UD for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:42:43 -0400 Received: from [140.186.70.92] (port=60889 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O486D-0007fW-75 for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:42:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O485o-0004gn-Ol for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:42:24 -0400 Received: from os.inf.tu-dresden.de ([141.76.48.99]:40301) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O485i-0004eI-4I for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 03:41:57 -0400 Received: from [217.9.48.20] (helo=[165.204.15.163]) by os.inf.tu-dresden.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.71) id 1O485f-0006ni-JO for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2010 09:41:51 +0200 Message-ID: <4BCD5ABF.6010601@os.inf.tu-dresden.de> Date: Tue, 20 Apr 2010 09:41:51 +0200 From: Martin Pohlack User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9pre) Gecko/20100217 Shredder/3.0.3pre MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: iimage.el and modification hooks Content-Type: multipart/mixed; boundary="------------070304070002010503080807" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 20 Apr 2010 03:48:03 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) This is a multi-part message in MIME format. --------------070304070002010503080807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I started to use iimage.el yesterday and like it. However, it still seems possible to *blindly* modify contents inside the display blocks which is confusing. Furthermore, if the regexp defining the block is destroyed that way, disabling iimage-mode does not remove the display block --- it will be stuck forever. I therefore use a modification hook for removing the display block in case the underlying text is modified. Please find the patch attached, in case you like it. Cheers, Martin Pohlack --------------070304070002010503080807 Content-Type: text/x-patch; name="iimage_modification-hooks.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="iimage_modification-hooks.diff" --- /home/mp26/src/emacs/lisp/iimage.el 2009-11-21 12:03:13.000000000 +0100 +++ iimage.el 2010-04-18 23:24:10.000000000 +0200 @@ -109,6 +109,19 @@ (defalias 'iimage-locate-file 'locate-file) +(defun iimage-modification-hook (beg end) + "Remove display property if a display region is modified." + ;;(debug-print "ii1 begin %d, end %d\n" beg end) + (let ((inhibit-modification-hooks t) + (beg (previous-single-property-change end 'display + nil (line-beginning-position))) + (end (next-single-property-change beg 'display + nil (line-end-position)))) + (when (and beg end (plist-get (text-properties-at beg) 'display)) + ;;(debug-print "ii2 begin %d, end %d\n" beg end) + (remove-text-properties beg end + '(display nil modification-hooks nil))))) + (defun iimage-mode-buffer (arg) "Display/undisplay images. With numeric ARG, display the images if and only if ARG is positive." @@ -128,9 +141,12 @@ iimage-mode-image-search-path)))) (if ing (add-text-properties (match-beginning 0) (match-end 0) - (list 'display (create-image file))) - (remove-text-properties (match-beginning 0) (match-end 0) - '(display))))))) + (list 'display (create-image file) + 'modification-hooks + (list 'iimage-modification-hook))) + (remove-list-of-text-properties + (match-beginning 0) (match-end 0) + '(display modification-hooks))))))) (set-buffer-modified-p modp))) ;;;###autoload --------------070304070002010503080807-- ------------=_1275944822-11711-1--