unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
@ 2014-08-11 12:09 Ivan Shmakov
  2014-08-11 14:47 ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Ivan Shmakov @ 2014-08-11 12:09 UTC (permalink / raw)
  To: 18246

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff, Size: 449 bytes --]

--- 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)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-11 12:09 bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too Ivan Shmakov
@ 2014-08-11 14:47 ` Stefan Monnier
  2014-08-11 18:57   ` Ivan Shmakov
                     ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-08-11 14:47 UTC (permalink / raw)
  To: Ivan Shmakov; +Cc: 18246

> 	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





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-11 14:47 ` Stefan Monnier
@ 2014-08-11 18:57   ` Ivan Shmakov
  2014-08-12  3:15   ` Richard Stallman
  2015-02-14  8:31   ` Ivan Shmakov
  2 siblings, 0 replies; 13+ messages in thread
From: Ivan Shmakov @ 2014-08-11 18:57 UTC (permalink / raw)
  To: 18246

>>>>> Stefan Monnier <monnier@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





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-11 14:47 ` Stefan Monnier
  2014-08-11 18:57   ` Ivan Shmakov
@ 2014-08-12  3:15   ` Richard Stallman
  2014-08-12 14:38     ` Eli Zaretskii
  2014-08-12 14:53     ` Stefan Monnier
  2015-02-14  8:31   ` Ivan Shmakov
  2 siblings, 2 replies; 13+ messages in thread
From: Richard Stallman @ 2014-08-12  3:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: ivan, 18246

[[[ 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.






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-12  3:15   ` Richard Stallman
@ 2014-08-12 14:38     ` Eli Zaretskii
  2014-08-13  3:59       ` Richard Stallman
  2014-08-12 14:53     ` Stefan Monnier
  1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2014-08-12 14:38 UTC (permalink / raw)
  To: rms; +Cc: ivan, 18246

> Date: Mon, 11 Aug 2014 23:15:28 -0400
> From: Richard Stallman <rms@gnu.org>
> Cc: ivan@siamics.net, 18246@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-12  3:15   ` Richard Stallman
  2014-08-12 14:38     ` Eli Zaretskii
@ 2014-08-12 14:53     ` Stefan Monnier
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-08-12 14:53 UTC (permalink / raw)
  To: Richard Stallman; +Cc: ivan, 18246

> 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





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-12 14:38     ` Eli Zaretskii
@ 2014-08-13  3:59       ` Richard Stallman
  2014-08-13 15:08         ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2014-08-13  3:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: ivan, 18246

[[[ 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.






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-13  3:59       ` Richard Stallman
@ 2014-08-13 15:08         ` Eli Zaretskii
  2014-08-13 22:50           ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2014-08-13 15:08 UTC (permalink / raw)
  To: rms; +Cc: ivan, 18246

> Date: Tue, 12 Aug 2014 23:59:01 -0400
> From: Richard Stallman <rms@gnu.org>
> CC: monnier@iro.umontreal.ca, ivan@siamics.net, 18246@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-13 15:08         ` Eli Zaretskii
@ 2014-08-13 22:50           ` Richard Stallman
  2014-08-14 18:14             ` Ivan Shmakov
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2014-08-13 22:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: ivan, 18246

[[[ 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.






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-13 22:50           ` Richard Stallman
@ 2014-08-14 18:14             ` Ivan Shmakov
  2014-08-14 18:26               ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Ivan Shmakov @ 2014-08-14 18:14 UTC (permalink / raw)
  To: 18246

>>>>> Richard Stallman <rms@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





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-14 18:14             ` Ivan Shmakov
@ 2014-08-14 18:26               ` Eli Zaretskii
  2014-08-14 19:25                 ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2014-08-14 18:26 UTC (permalink / raw)
  To: Ivan Shmakov; +Cc: 18246

> From: Ivan Shmakov <ivan@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-14 18:26               ` Eli Zaretskii
@ 2014-08-14 19:25                 ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-08-14 19:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Ivan Shmakov, 18246

> 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





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too
  2014-08-11 14:47 ` Stefan Monnier
  2014-08-11 18:57   ` Ivan Shmakov
  2014-08-12  3:15   ` Richard Stallman
@ 2015-02-14  8:31   ` Ivan Shmakov
  2 siblings, 0 replies; 13+ messages in thread
From: Ivan Shmakov @ 2015-02-14  8:31 UTC (permalink / raw)
  To: 18246-done

Version: 25.1

>>>>> Stefan Monnier <monnier@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





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-02-14  8:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-11 12:09 bug#18246: enriched-encode: should set inhibit-point-motion-hooks, too Ivan Shmakov
2014-08-11 14:47 ` Stefan Monnier
2014-08-11 18:57   ` Ivan Shmakov
2014-08-12  3:15   ` Richard Stallman
2014-08-12 14:38     ` Eli Zaretskii
2014-08-13  3:59       ` Richard Stallman
2014-08-13 15:08         ` Eli Zaretskii
2014-08-13 22:50           ` Richard Stallman
2014-08-14 18:14             ` Ivan Shmakov
2014-08-14 18:26               ` Eli Zaretskii
2014-08-14 19:25                 ` Stefan Monnier
2014-08-12 14:53     ` Stefan Monnier
2015-02-14  8:31   ` Ivan Shmakov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).