emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

diff-yank-handler


From: Kim F. Storm
Subject: diff-yank-handler
Date: Fri, 22 Jul 2005 14:41:18 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

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 <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]