Faster mercurial patch queue merging with emacs
As a follow-up to my previous post about merging mq reject in emacs, I thought I’d share some improvements to the process that I’ve made since then.
(interactive)
(let ((other-file
(if (string= (substring (buffer-file-name) -4 nil) ".rej")
(substring (buffer-file-name) 0 -4)
(concat (buffer-file-name) ".rej"))))
(if (file-exists-p other-file)
(save-selected-window
(switch-to-buffer-other-window (find-file-noselect other-file)))
(message "No alternate reject file found"))))
(defun kill-hg-reject ()
(interactive)
(let ((reject-file (concat (buffer-file-name) ".rej")))
(kill-buffer
(find-buffer-visiting reject-file))))
(global-set-key (kbd "C-c r") ’switch-hg-reject)
(global-set-key (kbd "C-x r") ‘kill-hg-reject)
It turns out that swapping back and forth between the reject and the original in a single window felt was quite inefficient. With these changes, the reject opens up in another window (think emacs terminology here) on C-c r, and I can kill it later with C-x r. This also works better with other modules like uniquify – the code from the previous post would fail when trying to access rejects associated with buffers name “Makefile.in|ipc”. No longer must you suffer the indignity of process! Merging can, and should, be fun! BEHOLD MY WORKS AND DESPAIR.