all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* diff-yank-handler
@ 2005-07-22 12:41 Kim F. Storm
  2005-07-22 20:02 ` diff-yank-handler Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Kim F. Storm @ 2005-07-22 12:41 UTC (permalink / raw)



diff-mode.el contains the following which isn't used anywhere.
I suppose this is due to the "FIXME" comment below.

What need to be done to complete this?

(defconst diff-yank-handler '(diff-yank-function))
(defun diff-yank-function (text)
  ;; FIXME: the yank-handler is now called separately on each piece of text
  ;; with a yank-handler property, so the next-single-property-change call
  ;; below will always return nil :-(   --stef
  (let ((mixed (next-single-property-change 0 'yank-handler text))
	(start (point)))
    ;; First insert the text.
    (insert text)
    ;; If the text does not include any diff markers and if we're not
    ;; yanking back into a diff-mode buffer, get rid of the prefixes.
    (unless (or mixed (derived-mode-p 'diff-mode))
      (undo-boundary)		; Just in case the user wanted the prefixes.
      (let ((re (save-excursion
		  (if (re-search-backward "^[><!][ \t]" start t)
		      (if (eq (char-after) ?!)
			  "^[!+- ][ \t]" "^[<>][ \t]")
		    "^[ <>!+-]"))))
	(save-excursion
	  (while (re-search-backward re start t)
	    (replace-match "" t t)))))))

I would suggest that we could add a 5th element to the yank-handler
indicating that the string covered by this yank-handler should
be combined with the next yank-handler.

We could then "FIXIT" with:

(defconst diff-yank-handler '(diff-yank-function nil nil nil t))


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: diff-yank-handler
  2005-07-22 12:41 diff-yank-handler Kim F. Storm
@ 2005-07-22 20:02 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2005-07-22 20:02 UTC (permalink / raw)
  Cc: emacs-devel

> diff-mode.el contains the following which isn't used anywhere.
> I suppose this is due to the "FIXME" comment below.

> What need to be done to complete this?

I think what needs to be done is to redefine the kill functions in diff-mode
buffers so as to add a yank-handler to the killed text.

> I would suggest that we could add a 5th element to the yank-handler
> indicating that the string covered by this yank-handler should
> be combined with the next yank-handler.

It may be a good alternative solution, but I'm not sure what that means.


        Stefan

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

end of thread, other threads:[~2005-07-22 20:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-22 12:41 diff-yank-handler Kim F. Storm
2005-07-22 20:02 ` diff-yank-handler Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.