Commit 8773bbd5 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Implemented "View diff"/"Se diff".

parent eca18bfb
2002-04-20 Per Cederqvist <>
Implemented "View diff"/"Se diff":
* commands2.el (lyskom-create-temp-file): New function.
(kom-diff-texts): New command.
* (lyskom-commands): Added kom-diff-texts.
* swedish-strings.el (lyskom-command): Added kom-diff-texts.
(lyskom-help-strings): Ditto.
* english-strings.el (lyskom-command): Added kom-diff-texts.
2002-04-20 David Byers <>
Move binding of 'a' to 'x' in the swedish keymaps:
......@@ -2528,6 +2528,82 @@ to the first text that NEW is a comment or footnote to."
(lyskom-create-text-buffer old old-text old-text-stat)
(lyskom-create-text-buffer new new-text new-text-stat))))
;;; ================================================================
;;; Se diff - View diff
;;; Run diff on two texts and insert the result.
;;; Author: Per Cederqvist
(defun lyskom-create-temp-file (text-no text text-stat)
"Create a temporary file containing TEXT, and return its file name."
(let ((file (make-temp-file (format "kom-diff-%d." text-no)))
(buf (lyskom-create-text-buffer text-no text text-stat)))
(write-region (point-min) (point-max) file)
(kill-buffer buf)
(def-kom-command kom-diff-texts (old new &optional switches)
"Show differences between text OLD and NEW.
When called interactively, it will prompt for the NEW text first,
defaulting to the last viewed texts. The OLD text number will default
to the first text that NEW is a comment or footnote to."
(let* ((n (lyskom-read-text-no-prefix-arg 'diff-what-text-new t))
(new-stat (blocking-do 'get-text-stat n))
(o (lyskom-read-number
(if (null new-stat)
(lyskom-error (lyskom-get-string 'no-such-text-no n))
(car (lyskom-text-stat-commented-texts new-stat))))))
o n
(if current-prefix-arg
(list (read-string "Diff switches: "
(if (stringp diff-switches)
(mapconcat 'identity diff-switches " "))))
(blocking-do-multiple ((old-text (get-text old))
(new-text (get-text new))
(old-text-stat (get-text-stat old))
(new-text-stat (get-text-stat new)))
(let* ((buf (current-buffer))
(oldfile (lyskom-create-temp-file old old-text old-text-stat))
(newfile (lyskom-create-temp-file new new-text new-text-stat))
(args (list "-L" (format "%d\t%s" old
(text-stat->creation-time old-text-stat)))
"-L" (format "%d\t%s" new
(text-stat->creation-time new-text-stat)))
oldfile newfile)))
(if switches
(setq args (append
(split-string (if (consp switches)
(mapconcat 'identity switches " ")
(if diff-switches
(setq args (append
(split-string (if (consp diff-switches)
(mapconcat 'identity diff-switches " ")
(set-buffer buf)
(let ((buffer-read-only nil))
(apply 'call-process diff-command nil buf nil args))
(delete-file oldfile)
(delete-file newfile))))
;;; ================================================================
;;; Skapa aux-item
......@@ -1859,6 +1859,7 @@ Number of sessions: %21#1d (total)
(kom-review-mail-headers . "Review mail headers")
(kom-compare-texts . "Compare two texts")
(kom-diff-texts . "View diff")
(kom-become-anonymous . "Become anonymous")
(kom-become-nonanonymous . "Become non-anonymous (come forth into the light)")
......@@ -1859,6 +1859,7 @@ Antal sessioner: %21#1d (totalt)
(kom-review-mail-headers . "terse brevhuvud")
(kom-compare-texts . "Jmfr tv texter")
(kom-diff-texts . "Se diff")
(kom-become-anonymous . "Bli anonym")
(kom-become-nonanonymous . "Bli icke-anonym (trd fram ur skuggorna)")
......@@ -2264,6 +2265,8 @@ Beg
(kom-compare-texts . "\
Jmfr tv texter med hjlp av ediff.")
(kom-diff-texts . "\
Jmfr tv texter med hjlp av diff.")
(kom-become-anonymous . "\
ndra klientens beteende s att du blir lite mer anonym. Det blir ven
......@@ -1804,6 +1804,7 @@ is a list of vectors, where each vector specifies an item.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment