From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: bug#34520: delete-matching-lines should report how many lines it deleted Date: Sat, 02 Mar 2019 22:04:06 -0500 Message-ID: References: <87o97aq6gz.fsf@jidanni.org> <87tvgoud56.fsf@mail.linkov.net> <83o96wk2mi.fsf@gnu.org> <87k1hjfvjd.fsf@mail.linkov.net> <871s3p0zdz.fsf@mail.linkov.net> Reply-To: rms@gnu.org Content-Type: text/plain; charset=Utf-8 Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="61536"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 03 04:04:45 2019 Return-path: Envelope-to: ged-emacs-devel@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 1h0HQj-000FtA-LA for ged-emacs-devel@m.gmane.org; Sun, 03 Mar 2019 04:04:45 +0100 Original-Received: from localhost ([127.0.0.1]:33483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0HQi-0000hh-Fc for ged-emacs-devel@m.gmane.org; Sat, 02 Mar 2019 22:04:44 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0HQ6-0000hA-Qv for emacs-devel@gnu.org; Sat, 02 Mar 2019 22:04:07 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:51443) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0HQ6-0006YM-FL; Sat, 02 Mar 2019 22:04:06 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1h0HQ6-0004cv-BQ; Sat, 02 Mar 2019 22:04:06 -0500 In-Reply-To: <871s3p0zdz.fsf@mail.linkov.net> (message from Juri Linkov on Sat, 02 Mar 2019 22:55:52 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233788 Archived-At: [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] You wrote: ====================================================================== Here is an experimental but extensible implementation that handles the case of formatting the recently added message taking into account grammatical number of its argument: (defvar i18n-translations-hash (make-hash-table :test 'equal)) (defun i18n-add-translation (_language-environment from to) (puthash from to i18n-translations-hash)) (i18n-add-translation "English" "Deleted %d matching lines" (lambda (format-string count) (if (= count 1) "Deleted %d matching line" "Deleted %d matching lines"))) (defun i18n-get-translation (format-string &rest args) (pcase (gethash format-string i18n-translations-hash) ((and (pred functionp) f) (apply f format-string args)) ((and (pred stringp) s) s) (_ format-string))) (advice-add 'message :around (lambda (orig-fun format-string &rest args) (apply orig-fun (apply 'i18n-get-translation format-string args) args)) '((name . message-i18n))) ====================================================================== It seems pretty good. When installing it, it should not use `advice-add'. Rather, `message' should call a list of functions. -- Dr Richard Stallman President, Free Software Foundation (https://gnu.org, https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org)