unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: ndame via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 49774@debbugs.gnu.org
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	[thread overview]
Message-ID: <0P47qwRVw_gf4GSeLbGeHw3KsnyW3MjTovMB-1X6PH6Dne-RYYD4_ZFV4pYEMoFk3NeihnjmKVCyEbS2N5dWvktWGMzoLnk6CRj4pfzBjuI=@protonmail.com> (raw)
In-Reply-To: <s4zd4P1uDdOsRMOZsQrqWQi7T1sQCybO0QM5HjHg1JbUeY45QBe2KZGBQ6hCz6sFmMkROkn3MKHGzKZzEIKPUVsDZCyiloxyCYkpNSavmvU=@protonmail.com>

[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]

‐‐‐‐‐‐‐ 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))))

[-- Attachment #2: Type: text/html, Size: 2217 bytes --]

      reply	other threads:[~2021-08-16 18:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 16:59 bug#49774: 27.1; if diff commands finds no differences then do not pop up a window ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-30  1:18 ` Dmitry Gutov
2021-07-30  4:18   ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-30 10:03     ` Lars Ingebrigtsen
2021-07-30 11:19       ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-30 11:24         ` Lars Ingebrigtsen
2021-07-30 11:47           ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-30 11:48             ` Lars Ingebrigtsen
2021-07-30 11:58               ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-30 12:44                 ` Dmitry Gutov
2021-07-30 13:19                   ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-30 18:47                   ` Lars Ingebrigtsen
2021-07-31 21:06                     ` Juri Linkov
2021-07-31 22:11                       ` Lars Ingebrigtsen
2021-08-02  1:07                     ` Richard Stallman
2022-08-22 10:30                       ` Lars Ingebrigtsen
2021-07-30 18:28 ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-16 18:29   ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='0P47qwRVw_gf4GSeLbGeHw3KsnyW3MjTovMB-1X6PH6Dne-RYYD4_ZFV4pYEMoFk3NeihnjmKVCyEbS2N5dWvktWGMzoLnk6CRj4pfzBjuI=@protonmail.com' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=49774@debbugs.gnu.org \
    --cc=laszlomail@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).