 ;;; in-memory-diff.el --- diff lines of two buffers
 
-;; Copyright (C) 2017 Alex Schroeder
+;; Copyright (C) 2017-2018 Alex Schroeder, Dan Harms
 
 ;; Author: Alex Schroeder <alex@gnu.org>
 ;; Version: 0.1
-;; Keywords: text
+;; Keywords: text tools unix
+;; URL: https://github.com/kensanata/in-memory-diff.git
 
 ;; This file is NOT part of GNU Emacs.
 

    (define-key map "q" 'bury-buffer)
    (define-key map (kbd "RET") 'in-memory-diff-visit)
    map)
  "Keymap for In Memory Diff mode")

(define-derived-mode in-memory-diff-mode fundamental-mode "extra-lines")

(defun in-memory-insert (lines1 lines2)
  "Insert all the lines of LINES1 not in LINES2
in the current buffer."
  (dolist (line lines1)
    (when (not (member line lines2))
      (insert line "\n"))))

(defun in-memory-diff (buffer1 buffer2)
  "Show the difference between two buffers

BUFFER1 and BUFFER2 are treated as a set of unordered lines, as
one would excpect for a file like ~/.authinfo.gpg, for example.
We don't use diff(1) to diff the buffers and don't write
temporary files to disk."
  (interactive "bBuffer A: \nbBuffer B: ")
  (let ((lines (mapcar (lambda (buf)
			 (with-current-buffer buf
			   (split-string (buffer-string) "\n")))
		       (list buffer1 buffer2))))
    
    (with-current-buffer (get-buffer-create "*A*")
      (let ((inhibit-read-only t))
	(erase-buffer)
	(apply 'in-memory-insert lines))
      (in-memory-diff-mode)
      (set (make-local-variable 'in-memory-this) buffer1)
      (set (make-local-variable 'in-memory-other) buffer2)
      (display-buffer (current-buffer)))
    (with-current-buffer (get-buffer-create "*B*")
      (let ((inhibit-read-only t))
	(erase-buffer)
	(apply 'in-memory-insert (reverse lines)))
      (in-memory-diff-mode)
      (set (make-local-variable 'in-memory-this) buffer2)
      (set (make-local-variable 'in-memory-other) buffer1)

    (with-current-buffer in-memory-this
      (goto-char (point-min))
      (while (re-search-forward (concat "^" (regexp-quote line) "$") nil t)
        (replace-match "")))
    (in-memory-delete-this-line)))

(defun in-memory-diff-visit ()
