Skip to content

Instantly share code, notes, and snippets.

@agzam
Last active July 27, 2020 15:46
Show Gist options
  • Select an option

  • Save agzam/792ccef7eb57e9bcb27253be1bea16f3 to your computer and use it in GitHub Desktop.

Select an option

Save agzam/792ccef7eb57e9bcb27253be1bea16f3 to your computer and use it in GitHub Desktop.

Revisions

  1. agzam revised this gist Jul 1, 2020. 1 changed file with 17 additions and 8 deletions.
    25 changes: 17 additions & 8 deletions diff-last-two-kills.el
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,20 @@
    (defun diff-last-two-kills (&optional ediff?)
    "Diff last couple of things in the kill-ring. With prefix open ediff."
    (interactive "P")
    (let ((old "/tmp/old-kill") (new "/tmp/new-kill"))
    (with-temp-file new
    (insert (current-kill 0 t)))
    (with-temp-file old
    (insert (current-kill 1 t)))
    (if ediff?
    (ediff old new)
    (diff old new "-u" t))))
    (let* ((old "/tmp/old-kill")
    (new "/tmp/new-kill")
    (prev-ediff-quit-hook ediff-quit-hook))
    (cl-flet ((kill-temps
    ()
    (dolist (f (list old new))
    (kill-buffer (find-buffer-visiting f)))
    (setq ediff-quit-hook prev-ediff-quit-hook)))
    (with-temp-file new
    (insert (current-kill 0 t)))
    (with-temp-file old
    (insert (current-kill 1 t)))
    (if ediff?
    (progn
    (add-hook 'ediff-quit-hook #'kill-temps)
    (ediff old new))
    (diff old new "-u" t)))))
  2. agzam renamed this gist Jun 30, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. agzam created this gist Jun 30, 2020.
    11 changes: 11 additions & 0 deletions funcs.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    (defun diff-last-two-kills (&optional ediff?)
    "Diff last couple of things in the kill-ring. With prefix open ediff."
    (interactive "P")
    (let ((old "/tmp/old-kill") (new "/tmp/new-kill"))
    (with-temp-file new
    (insert (current-kill 0 t)))
    (with-temp-file old
    (insert (current-kill 1 t)))
    (if ediff?
    (ediff old new)
    (diff old new "-u" t))))