From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer Date: Fri, 05 Apr 2019 03:13:02 +0100 Message-ID: <87wok919ox.fsf@tcd.ie> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="158575"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 35141@debbugs.gnu.org To: Alex Murray Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 05 04:18:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCEQm-000f6F-Go for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Apr 2019 04:18:12 +0200 Original-Received: from localhost ([127.0.0.1]:34801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCEQl-0000vP-94 for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Apr 2019 22:18:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCEQc-0000ut-P1 for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2019 22:18:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hCEMk-00060Q-NF for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2019 22:14:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59587) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hCEMk-0005yH-8K for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2019 22:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hCEMj-0006G4-Nn for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2019 22:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Apr 2019 02:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35141 X-GNU-PR-Package: emacs Original-Received: via spool by 35141-submit@debbugs.gnu.org id=B35141.155443039423974 (code B ref 35141); Fri, 05 Apr 2019 02:14:01 +0000 Original-Received: (at 35141) by debbugs.gnu.org; 5 Apr 2019 02:13:14 +0000 Original-Received: from localhost ([127.0.0.1]:44898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCELx-0006Eb-5f for submit@debbugs.gnu.org; Thu, 04 Apr 2019 22:13:13 -0400 Original-Received: from mail-ed1-f51.google.com ([209.85.208.51]:37346) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCELu-0006EO-Pw for 35141@debbugs.gnu.org; Thu, 04 Apr 2019 22:13:11 -0400 Original-Received: by mail-ed1-f51.google.com with SMTP id v21so4084580edq.4 for <35141@debbugs.gnu.org>; Thu, 04 Apr 2019 19:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=40XskszhKpPFCb99xtA6qsnE6bBQxGxt1SDYAS9mK/w=; b=DVPhxRTIN7m/0m1SZRsVr9qGrMKSoualKGGkNVAi3VNHzkwJ87MX/kjaLLYFUB4Wfh pUb2R26jgDZDDfUQ1tBLjWRq8dyNMWKwj5Yc0FVIlKaeybQ5EeWgLpj0mmYq9IpfRUN6 IFF9F5Oz9XCUa9CnyrH76917RiFXwLQPeIh+jmrii/ldeLlifKjAuLxmtSfbV1FwNpoL l5OPvBlQlQEs9whu9tySYWdjHnEtRQE+DGNUfpbNKhkPvVZ5nOezg76x6I1K6ME6LXzP F8q1f+2WyCAThTmjxHJirIvmNV+qQmQtA/e7BayRMG3ZrUZrmJXMzhPoEUM1B0dNqKiL CfJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=40XskszhKpPFCb99xtA6qsnE6bBQxGxt1SDYAS9mK/w=; b=JtgAhfXi8K0McjBcKPc+R/NuUVo0cUNTfwnenGei3OHZ18kD3ocmkNk+P6Zj6511WR IFsbZyyohSuP3vMGt0mmMvq5+VBXnXYg0fFmeOD6LqHPtngQY6u5pzYJo6XvaGU4F6uZ jtzixcwrhpjMatsrGE5UHltjmbMvEhStbGohyLBYF0kxkNIlBKGy22APFZ+QpnnU+PJU O8mqTK/UynqZ795PRknj8nanXqUHMlgw+9Sr2eJ63Rpm/cOkqqAS5J9YdfyoLF8rhYkD d9O8JEVPk757hY5RaV8VJQjXZ7BV+EMECVsnCtjfOVRApY0tNpRhYcyquzBmSaYiWJz5 s7+A== X-Gm-Message-State: APjAAAVcXvcDMcPQk7xHCEd7Z01b3zn68fULD1LQnSU9P6UX1NHAGYoG tX1fjKX057SF0xKh3u5mCRabPg== X-Google-Smtp-Source: APXvYqwtR5blEI5RbHnhSw6Oz4Ot/lOMyQMkRagQ9PGrHTRsBVnIOGlq2Zapns4ci5IEHVTmIVaVrA== X-Received: by 2002:a17:906:364f:: with SMTP id r15mr5591137ejb.215.1554430384949; Thu, 04 Apr 2019 19:13:04 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:20c2:134e:4f3a:683a]) by smtp.gmail.com with ESMTPSA id s3sm3783227ejk.17.2019.04.04.19.13.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 04 Apr 2019 19:13:03 -0700 (PDT) In-Reply-To: (Alex Murray's message of "Thu, 4 Apr 2019 17:02:24 +1030") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:157197 Archived-At: Alex Murray writes: > Attached is a patch which converts erc-desktop-notifications.el to > lexical-binding and adds a default action to the generated > notifications so that when they are clicked we automatically switch to > the originating buffer. SGTM. > From 52b63272eed8aaafcd931e833ad006dd425d6512 Mon Sep 17 00:00:00 2001 > From: Alex Murray > Date: Thu, 4 Apr 2019 16:49:48 +1030 > Subject: [PATCH] Switch to originating erc buffer when clicking desktop > notification > > * lisp/erc/erc-desktop-notifications.el: Switch to lexical-binding and > add a default action to the desktop notification which switches to > the buffer from which the notification originated. As such clicking > on the notification now automatically switches to that buffer. Please mention the name of the function changed: * lisp/erc/erc-desktop-notifications.el: Switch to lexical-binding. (erc-notifications-notify): Add ... Unless you have completed your copyright assignment for contributions to Emacs, the commit message should also include: Copyright-paperwork-exempt: yes For more details, see the file CONTRIBUTE. > diff --git a/ChangeLog.3 b/ChangeLog.3 > index 235c8bb180..3819d6b4fe 100644 > --- a/ChangeLog.3 > +++ b/ChangeLog.3 > @@ -1,3 +1,10 @@ > +2019-04-04 Alex Murray > + > + * lisp/erc/erc-desktop-notifications.el: Use lexical-binding. > + (erc-notifications-notify): Add a default action to > + notifications which switches to the buffer from which the > + notification originated. > + > 2019-03-20 Eli Zaretskii > > Improve indexing of the user manual ChangeLog files are no longer maintained by hand, but rather generated from Git commit messages. > diff --git a/lisp/erc/erc-desktop-notifications.el b/lisp/erc/erc-desktop-notifications.el > index 56b93925ce..c1b812c119 100644 > --- a/lisp/erc/erc-desktop-notifications.el > +++ b/lisp/erc/erc-desktop-notifications.el > @@ -59,11 +59,17 @@ > This will replace the last notification sent with this function." > (dbus-ignore-errors > (setq erc-notifications-last-notification > - (notifications-notify :bus erc-notifications-bus > - :title (xml-escape-string nick) > - :body (xml-escape-string msg) > - :replaces-id erc-notifications-last-notification > - :app-icon erc-notifications-icon)))) > + (let ((channel (current-buffer))) > + (notifications-notify :bus erc-notifications-bus > + :title (format "%s in %s" > + (xml-escape-string nick) > + (buffer-name channel)) No need for buffer-name; you can pass buffers directly to "%s". > + :body (xml-escape-string msg) > + :replaces-id erc-notifications-last-notification > + :app-icon erc-notifications-icon > + :actions '("default" "Switch to buffer") > + :on-action #'(lambda (id action) > + (switch-to-buffer channel))))))) This should instead be something like the following: (lambda (&rest _) (pop-to-buffer channel)) In particular, lambdas don't need to be quoted with #', pop-to-buffer is far better behaved than switch-to-buffer, and unused argument names should either start with an underscore or be omitted. Thanks, -- Basil