bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49774: 27.1; if diff commands finds no differences then do not pop u


From: ndame
Subject: bug#49774: 27.1; if diff commands finds no differences then do not pop up a window
Date: Mon, 16 Aug 2021 18:29:07 +0000

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, July 30th, 2021 at 8:28 PM, ndame <laszlomail@protonmail.com> wrote:


If there are no differences then emacs should just show this in a message instead of popping up a window with not useful content.

Just a simple implementation with advices for the time being for those who prefer this:

(advice-add 'diff :around 'my-diff)

(defun my-diff (orig-fun &rest args)
  (flet ((display-buffer (buf) buf))
    (apply orig-fun args)))


(advice-add 'diff-sentinel :after 'my-diff-sentinel)

(defun my-diff-sentinel (code &rest args)
  (if (equal code 0)
      (message "No differences.")   
    (display-buffer (current-buffer))))



The permanent sentinel advice affects non-interactive diffs too (diff-no-select), so a better solution is to add and remove that advice on demand:

(advice-add 'diff :around 'my-diff)

(defun my-diff (orig-fun &rest args)
  (advice-add 'diff-sentinel :after 'my-diff-sentinel)
  (flet ((display-buffer (buf) buf))
    (apply orig-fun args)))


(defun my-diff-sentinel (code &rest args)
  (advice-remove 'diff-sentinel 'my-diff-sentinel)
  (if (equal code 0)
      (message "No differences.")   
    (display-buffer (current-buffer))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]