branch: elpa/helm commit e1ec1b3d96d60da563a02daa4bc5276cd5f69df7 Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
Change behavior of helm-buffer-toggle-diff When buffer is modified inside emacs by user and not saved (orange) use diff file buf, otherwise (modified outside, red) use diff buf file. IOW in first case, a change has been done on buffer but not file, and on second case the change has been done on file but not buffer, using different order in argument makes the diff easier to understand. --- helm-buffers.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/helm-buffers.el b/helm-buffers.el index ba8b0b9ed3..40d7595ff3 100644 --- a/helm-buffers.el +++ b/helm-buffers.el @@ -848,11 +848,16 @@ If REGEXP-FLAG is given use `query-replace-regexp'." (helm-aif (get-buffer-window "*Diff*" 'visible) (progn (kill-buffer "*Diff*") (set-window-buffer it helm-current-buffer)) - (let ((buf (get-buffer candidate))) - (if (buffer-file-name buf) - (diff-buffer-with-file buf) - (user-error "Buffer `%s' is not associated to a file" - (buffer-name buf)))))) + ;; Expect the prop at pos 2 because of icon at 1. + (let* ((type (get-text-property 2 'type (helm-get-selection nil 'withprop))) + (buf (helm-aif (get-buffer candidate) + (or (buffer-base-buffer it) it))) + (file (buffer-file-name buf))) + (cl-assert file nil (format "Buffer `%s' is not associated to a file" + (buffer-name buf))) + (if (eq type 'modout) + (diff buf file) ; Buffer modified externally. + (diff file buf))))) ; Buffer modified inside emacs and not saved. (helm-make-persistent-command-from-action helm-buffer-diff-persistent "Toggle diff buffer without quitting helm."