GNU bug report logs - #18246
enriched-encode: should set inhibit-point-motion-hooks, too

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Mon, 11 Aug 2014 12:10:02 UTC

Severity: minor

Tags: patch

Fixed in version 25.1

Done: Ivan Shmakov <ivan <at> siamics.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18246 in the body.
You can then email your comments to 18246 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Mon, 11 Aug 2014 12:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Shmakov <ivan <at> siamics.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 11 Aug 2014 12:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: submit <at> debbugs.gnu.org
Subject: enriched-encode: should set inhibit-point-motion-hooks, too 
Date: Mon, 11 Aug 2014 12:09:27 +0000
[Message part 1 (text/plain, inline)]
Package:  emacs

	While enriched-encode already sets inhibit-read-only to t to
	avoid issues with any text bearing the read-only property [1] in
	the encoded part, it doesn’t yet set inhibit-point-motion-hooks,
	which easily results in incorrect encoding should text being
	encoded contain parts protected with the ‘intangible’ property.

	Example:

(with-temp-buffer
  (insert "Hello, world!\n")
  (re-search-backward "\\<")
  (put-text-property (point) (point-max) 'intangible t)
  (put-text-property (+ -1 (point)) (+ 1 (point)) 'face 'bold)
  (put-text-property (+  2 (point)) (+ 3 (point)) 'face 'italic)
  (enriched-encode (point-min) (point-max) nil)
  (buffer-substring-no-properties (point-min) (point-max)))
"Content-Type: text/enriched
Text-Width: 72

Hello,<bold> <</bold>italic>world!
</italic>"

	With the trivial patch MIMEd, this results in the following
	(correct) string instead:

"Content-Type: text/enriched
Text-Width: 72

Hello,<bold> w</bold>o<italic>r</italic>ld!
"

[1] http://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Properties.html

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A
[Message part 2 (text/x-diff, inline)]
--- a/lisp/textmodes/enriched.el
+++ b/lisp/textmodes/enriched.el
@@ -314,7 +314,8 @@ the region, and the START and END of each region."
 ;;;###autoload
 (defun enriched-encode (from to orig-buf)
   (if enriched-verbose (message "Enriched: encoding document..."))
-  (let ((inhibit-read-only t))
+  (let ((inhibit-read-only t)
+	(inhibit-point-motion-hooks t))
     (save-restriction
       (narrow-to-region from to)
       (delete-to-left-margin)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Mon, 11 Aug 2014 14:48:02 GMT) Full text and rfc822 format available.

Message #8 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ivan Shmakov <ivan <at> siamics.net>
Cc: 18246 <at> debbugs.gnu.org
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Mon, 11 Aug 2014 10:47:24 -0400
> 	the encoded part, it doesn’t yet set inhibit-point-motion-hooks,
> 	which easily results in incorrect encoding should text being
> 	encoded contain parts protected with the ‘intangible’ property.

`intangible' is evil, nasty, and sucks rocks.
Your patch is probably OK, but even better would be to fix the code that
uses `intangible'.

So, do you happen to know why there was a `intangible' in the way?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Mon, 11 Aug 2014 18:59:02 GMT) Full text and rfc822 format available.

Message #11 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: 18246 <at> debbugs.gnu.org
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Mon, 11 Aug 2014 18:57:46 +0000
>>>>> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

 >> the encoded part, it doesn’t yet set inhibit-point-motion-hooks,
 >> which easily results in incorrect encoding should text being encoded
 >> contain parts protected with the ‘intangible’ property.

 > `intangible' is evil, nasty, and sucks rocks.  Your patch is probably
 > OK, but even better would be to fix the code that uses `intangible'.

 > So, do you happen to know why there was a `intangible' in the way?

	Of the packages I use, ERC and Gnus make use of ‘intangible’ by
	default.  Specifically, the default for erc-timestamp-intangible
	is ‘t’, and for gnus-hidden-properties it’s ‘invisible t
	intangible t’ – which, per (elisp.info) Special Properties,
	is also unnecessary:

    […] A common misuse is to put an intangible property on invisible
    text, which is actually unnecessary since the command loop will move
    point outside of the invisible text at the end of each command
    anyway.  […]

	Gnus, however, appears to use overlays extensively for
	highlighting, while overlays, in turn, seem to be completely
	ignored by enriched.el, thus making enriched-encode unlikely to
	cause issues when called over Gnus buffers.

	It seems that the property is also used by RefTeX and SES, but I
	haven’t found any use to either yet.

$ grep -irE --include=\*.el -- "put-text-property\\s.*'intangible" lisp
lisp/erc/erc-stamp.el:	(erc-put-text-property from (1+ (point)) 'intangible t)))))
lisp/erc/erc-stamp.el:	     (erc-put-text-property 0 (length ts) 'intangible t ts))
lisp/textmodes/reftex-toc.el:      (put-text-property (point-min) (point) 'intangible t)
lisp/textmodes/reftex-index.el:      (put-text-property 1 (point) 'intangible t)
lisp/ses.el:	(put-text-property startpos (point) 'intangible
lisp/ses.el:	(put-text-property pos end 'intangible sym)))
lisp/ses.el:      (put-text-property pos end 'intangible new-name))
lisp/gnus/gnus-uu.el:	      (put-text-property (point-min) (point-max) 'intangible nil))
$ 

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Tue, 12 Aug 2014 03:16:02 GMT) Full text and rfc822 format available.

Message #14 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 18246 <at> debbugs.gnu.org, ivan <at> siamics.net
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Mon, 11 Aug 2014 23:15:28 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Whatever problems `intangible' may have, we need some such feature
to make it convenient to set up forms for the user to fill in.

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Tue, 12 Aug 2014 14:40:03 GMT) Full text and rfc822 format available.

Message #17 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: rms <at> gnu.org
Cc: 18246 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, ivan <at> siamics.net
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Tue, 12 Aug 2014 17:38:59 +0300
> Date: Mon, 11 Aug 2014 23:15:28 -0400
> From: Richard Stallman <rms <at> gnu.org>
> Cc: ivan <at> siamics.net, 18246 <at> debbugs.gnu.org
> 
> Whatever problems `intangible' may have, we need some such feature
> to make it convenient to set up forms for the user to fill in.

We can do that without `intangible': just use display properties or
overlays for the parts where you don't want the cursor to enter.  The
default behavior for point motions with text that comes from display
properties or overlay strings is to skip such text.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Tue, 12 Aug 2014 14:54:01 GMT) Full text and rfc822 format available.

Message #20 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Richard Stallman <rms <at> gnu.org>
Cc: 18246 <at> debbugs.gnu.org, ivan <at> siamics.net
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Tue, 12 Aug 2014 10:53:37 -0400
> Whatever problems `intangible' may have, we need some such feature
> to make it convenient to set up forms for the user to fill in.

Not sure what's the relationship between intangible and forms: the use
of forms I see most frequently in Emacs is Custom (using the forms
provided by the widget library) and it doesn't need/use
intangible, AFAICT.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Wed, 13 Aug 2014 04:00:03 GMT) Full text and rfc822 format available.

Message #23 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18246 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, ivan <at> siamics.net
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Tue, 12 Aug 2014 23:59:01 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

    We can do that without `intangible': just use display properties or
    overlays for the parts where you don't want the cursor to enter.

I am not completely sure what you mean.  Are you saying to do this
with text that is really in the buffer, just made to appear by display
properties?

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Wed, 13 Aug 2014 15:09:02 GMT) Full text and rfc822 format available.

Message #26 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: rms <at> gnu.org
Cc: 18246 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, ivan <at> siamics.net
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Wed, 13 Aug 2014 18:08:46 +0300
> Date: Tue, 12 Aug 2014 23:59:01 -0400
> From: Richard Stallman <rms <at> gnu.org>
> CC: monnier <at> iro.umontreal.ca, ivan <at> siamics.net, 18246 <at> debbugs.gnu.org
> 
>     We can do that without `intangible': just use display properties or
>     overlays for the parts where you don't want the cursor to enter.
> 
> I am not completely sure what you mean.  Are you saying to do this
> with text that is really in the buffer, just made to appear by display
> properties?

I meant to display the "intangible" text as display properties or
overlay strings.  Whether the text actually comes from the buffer (and
the display property covers it) or is consed out of thin air is not
important for the point I wanted to make.

We do something like that in report-emacs-bug.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Wed, 13 Aug 2014 22:51:02 GMT) Full text and rfc822 format available.

Message #29 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18246 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, ivan <at> siamics.net
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Wed, 13 Aug 2014 18:50:04 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

    I meant to display the "intangible" text as display properties or
    overlay strings.  Whether the text actually comes from the buffer (and
    the display property covers it) or is consed out of thin air is not
    important for the point I wanted to make.

For some purposes, that is true.  Maybe using the 'display' property
is good enough.  I have a feeling that it will seem anomalous to
users in some cases, but that is just a feeling.

One anomalous case for the 'display' property is searching in the buffer.
It does not find the text that appears via the 'display' property 
because that text is not really in the buffer.  With 'intangible',
search would find it even though point could not appear right there.

Another option would be to use text that is read-only but not intangible.
Maybe users won't be disturbed by being able to move point to the middle
of fixed text in the form.

I feel that none of these offers behavior that is really right and
smooth for a form.  I think this is an area for improvement in Emacs.

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Thu, 14 Aug 2014 18:15:02 GMT) Full text and rfc822 format available.

Message #32 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: 18246 <at> debbugs.gnu.org
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too 
Date: Thu, 14 Aug 2014 18:14:25 +0000
>>>>> Richard Stallman <rms <at> gnu.org> writes:

[…]

 > Another option would be to use text that is read-only but not
 > intangible.  Maybe users won't be disturbed by being able to move
 > point to the middle of fixed text in the form.

	For one thing, I actually consider the ability to move point to
	the middle of virtually /any/ text, including “fixed,” in Emacs
	(it’s not just forms, – think of tmm-menubar, for instance, or
	minibuffer prompts) to be a considerable /advantage./  And it
	gets especially useful when, say, writing a guide, – copying
	text from menus, forms, etc. is not nearly as easy in the
	majority of the modern (non-tty) software.

	(That being said, I believe it’s easier to point the reader to
	M-x foo-do-something than to Menu Bar → Foo → Do Something,
	so I’d say that menus are not as important to Emacs as they are
	to some other software, anyway.)

 > I feel that none of these offers behavior that is really right and
 > smooth for a form.  I think this is an area for improvement in Emacs.

	I’m all for improvements to Emacs.  In the case of ‘intangible’,
	however, – I’m out of ideas.

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Thu, 14 Aug 2014 18:27:02 GMT) Full text and rfc822 format available.

Message #35 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ivan Shmakov <ivan <at> siamics.net>
Cc: 18246 <at> debbugs.gnu.org
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Thu, 14 Aug 2014 21:26:17 +0300
> From: Ivan Shmakov <ivan <at> siamics.net>
> Date: Thu, 14 Aug 2014 18:14:25 +0000
> 
> 	For one thing, I actually consider the ability to move point to
> 	the middle of virtually /any/ text, including “fixed,” in Emacs
> 	(it’s not just forms, – think of tmm-menubar, for instance, or
> 	minibuffer prompts) to be a considerable /advantage./  And it
> 	gets especially useful when, say, writing a guide, – copying
> 	text from menus, forms, etc. is not nearly as easy in the
> 	majority of the modern (non-tty) software.

Since Emacs knows about every piece of text it displays, there should
be no problem to have M-w or whatever copy into the
selection/clipboard text that comes from overlays or display
properties.  There are no obstacles here, just coding.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Thu, 14 Aug 2014 19:26:02 GMT) Full text and rfc822 format available.

Message #38 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18246 <at> debbugs.gnu.org, Ivan Shmakov <ivan <at> siamics.net>
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
Date: Thu, 14 Aug 2014 15:25:10 -0400
> Since Emacs knows about every piece of text it displays, there should
> be no problem to have M-w or whatever copy into the
> selection/clipboard text that comes from overlays or display
> properties.  There are no obstacles here, just coding.

I don't think there's a strong need for it (tho it would occasionally
be handy).  But I agree with Ivan's point that there's no need to make
things intangible at all, usually: if the user wants to move outside of
the intended fields of a form, there's no reason to prevent him from
doing that.
The Widget library has done that forever and I've heard no complaint
about this aspect of the library.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18246; Package emacs. (Fri, 21 Nov 2014 10:59:02 GMT) Full text and rfc822 format available.

Message #41 received at 18246 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 18824 <at> debbugs.gnu.org, 18850 <at> debbugs.gnu.org, 18246 <at> debbugs.gnu.org,
 18175 <at> debbugs.gnu.org
Subject: (ping) Emacs bugs with patches? 
Date: Fri, 21 Nov 2014 10:57:53 +0000
	Stefan, you’ve previously commented on several of the bug
	reports I’ve suggested patches for.  Could you please revisit
	these patches and either commit or explicitly reject them?
	(Any suggestion on how, if at all, do I improve them in the
	latter case will be appreciated.)

	The bug reports in question are as follows.

	TIA.

    http://debbugs.gnu.org/18175  Use (mapc 'switch-to-buffer …) in
	files.el (was: mapcar.)
    http://debbugs.gnu.org/18246  Use inhibit-point-motion-hooks
	(in addition to inhibit-read-only) in enriched-encode.
    http://debbugs.gnu.org/18824  New diff-check-labels function
	(split off diff-no-select)
    http://debbugs.gnu.org/18850  Use diff-check-labels and the --label
	option to diff (was: -L – deprecated) in smerge-mode.el

-- 
FSF associate member #7257  np. По полям, за рекой — Иллет   … B6A0 230E 334A




Added tag(s) patch. Request was from Ivan Shmakov <ivan <at> siamics.net> to control <at> debbugs.gnu.org. (Fri, 26 Dec 2014 17:51:02 GMT) Full text and rfc822 format available.

Reply sent to Ivan Shmakov <ivan <at> siamics.net>:
You have taken responsibility. (Sat, 14 Feb 2015 08:33:02 GMT) Full text and rfc822 format available.

Notification sent to Ivan Shmakov <ivan <at> siamics.net>:
bug acknowledged by developer. (Sat, 14 Feb 2015 08:33:02 GMT) Full text and rfc822 format available.

Message #48 received at 18246-done <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: 18246-done <at> debbugs.gnu.org
Subject: Re: bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too 
Date: Sat, 14 Feb 2015 08:31:56 +0000
Version: 25.1

>>>>> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

[…]

 > Your patch is probably OK,

	I’ve pushed this change back in January; closing.

commit 172854461531ac7ad11b4490adc148e7a42a9fb3
CommitDate: 2015-01-17 19:34:50 +0000

    Fix: inhibit point motion hooks when encoding an enriched document.
    
    * lisp/textmodes/enriched.el (enriched-encode): Use
    inhibit-point-motion-hooks in addition to inhibit-read-only.
    
    Fixes: debbugs:18246

[…]

-- 
FSF associate member #7257  np. Undercurrent — Jami Sieber   … B6A0 230E 334A




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 14 Mar 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 46 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.