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

Implemented "View diff"/"Se diff".

parent eca18bfb
2002-04-20 Per Cederqvist <ceder@ceder.dyndns.org>
Implemented "View diff"/"Se diff":
* commands2.el (lyskom-create-temp-file): New function.
(kom-diff-texts): New command.
* vars.el.in (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 <david.byers@swipnet.se>
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)
file))
(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."
(interactive
(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
'diff-what-text-old
(if (null new-stat)
(lyskom-error (lyskom-get-string 'no-such-text-no n))
(car (lyskom-text-stat-commented-texts new-stat))))))
(list
o n
(if current-prefix-arg
(list (read-string "Diff switches: "
(if (stringp diff-switches)
diff-switches
(mapconcat 'identity diff-switches " "))))
nil))))
(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
(lyskom-format-time
'timeformat-yyyy-mm-dd-hh-mm-ss
(text-stat->creation-time old-text-stat)))
"-L" (format "%d\t%s" new
(lyskom-format-time
'timeformat-yyyy-mm-dd-hh-mm-ss
(text-stat->creation-time new-text-stat)))
oldfile newfile)))
(if switches
(setq args (append
(split-string (if (consp switches)
(mapconcat 'identity switches " ")
switches))
args))
(if diff-switches
(setq args (append
(split-string (if (consp diff-switches)
(mapconcat 'identity diff-switches " ")
diff-switches))
args))))
(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.
kom-review-mail-headers
kom-compare-texts
kom-diff-texts
kom-become-anonymous
kom-become-nonanonymous
......
Markdown is supported
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