unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Question about intended behavior of 'insert-for-yank-1'.
@ 2016-09-12  5:17 Karl Fogel
  2016-09-12 16:59 ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Karl Fogel @ 2016-09-12  5:17 UTC (permalink / raw)
  To: Emacs Devel

The doc string for 'insert-for-yank-1' says:

  [...]
  If STRING has a non-nil ‘yank-handler’ property on its first
  character, the normal insert behavior is altered.  The value of
  the ‘yank-handler’ property must be a list of one to four
  elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO).
  FUNCTION, if non-nil, should be a function of one argument, an
   object to insert; it is called instead of ‘insert’.
  PARAM, if present and non-nil, replaces STRING as the argument to
   FUNCTION or ‘insert’; e.g. if FUNCTION is ‘yank-rectangle’, PARAM
   may be a list of strings to insert as a rectangle.
  [...]

This implies that when the `yank-handler' property is present, then when PARAM is nil, the string passed to FUNCTION should be STRING.  That is, the entire length of STRING, even if the `yank-handler' property is set only on STRING's first character.

However, the way it actually behaves is that if you set the property on (say) exactly the first character of STRING, then, assuming you rely on the implicit parameter passing, what gets passed to FUNCTION is a string consisting of just the first character of STRING :-).  Later, when you yank with C-y, that's all you'll get.

Now, this might be a reasonable behavior -- after all, if one wanted the entirety of STRING passed, then maybe one should set the property on all of STRING -- but it's not what's actually documented.

Should I update the documentation to clarify?  Or should the behavior change instead?

(By the way, I have not tested what happens if you set that property on multiple disjoint extents of STRING.  Does FUNCTION get passed a newly-created concatenation of all the stretches of string that had the property?  I have no idea.  If the recommendation here is just to fix the documentation, though, then I'll do that testing.)

Best regards,
-Karl



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

end of thread, other threads:[~2016-10-04 21:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12  5:17 Question about intended behavior of 'insert-for-yank-1' Karl Fogel
2016-09-12 16:59 ` Eli Zaretskii
2016-09-12 17:15   ` Karl Fogel
2016-09-12 18:32     ` Eli Zaretskii
2016-09-12 22:36       ` Karl Fogel
2016-09-12 22:54         ` Drew Adams
2016-09-12 23:08           ` Karl Fogel
2016-10-03  0:53           ` Karl Fogel
2016-10-03  3:17             ` Noam Postavsky
2016-10-03  6:53               ` Eli Zaretskii
2016-10-03 19:21               ` Karl Fogel
2016-10-03  6:44             ` Eli Zaretskii
2016-10-03 19:17               ` Karl Fogel
2016-10-04  6:03                 ` Eli Zaretskii
2016-10-04 17:40                   ` Karl Fogel
2016-10-04 18:19                     ` Eli Zaretskii
2016-10-04 20:16                       ` Davis Herring
2016-10-04 21:04                       ` Karl Fogel

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