From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Is there a way to get the last message? Date: Sun, 28 May 2017 13:18:47 +0200 Message-ID: <87lgphp6ug.fsf@rosalinde> References: <87r2z92r2z.fsf@jane> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1495970381 7470 195.159.176.226 (28 May 2017 11:19:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 May 2017 11:19:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: Help Gnu Emacs mailing list To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 28 13:19:37 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEwES-0001k6-Cb for geh-help-gnu-emacs@m.gmane.org; Sun, 28 May 2017 13:19:36 +0200 Original-Received: from localhost ([::1]:43471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEwEU-0002A2-Tl for geh-help-gnu-emacs@m.gmane.org; Sun, 28 May 2017 07:19:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEwDx-00028X-2Z for help-gnu-emacs@gnu.org; Sun, 28 May 2017 07:19:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEwDs-0001iE-4U for help-gnu-emacs@gnu.org; Sun, 28 May 2017 07:19:05 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:50453) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dEwDr-0001hq-Q0 for help-gnu-emacs@gnu.org; Sun, 28 May 2017 07:19:00 -0400 Original-Received: from rosalinde ([83.135.4.33]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M5dMm-1e7rFZ3CeG-00xYkh; Sun, 28 May 2017 13:18:49 +0200 In-Reply-To: <87r2z92r2z.fsf@jane> (Marcin Borkowski's message of "Sun, 28 May 2017 12:50:12 +0200") X-Provags-ID: V03:K0:obyuWPq18UW+ENSxABcDn68sC3cwLMw0lcqRqfPZ1OEMtP+humJ PwPQy/g4soUpNpiqBq1zv8pTNDFg/pzYiSGDpb0WGJeKi2z1xA3EegxjVMOWzyl6shqDFHB /nV7/2UgmS8Sk+RKeSPhOUtm/UgKdFKKMsxayPFNq82G724iPJGq6Yp2fOtRie5DBfC91oZ b/tFcSxi4b9UD8PaHvGuw== X-UI-Out-Filterresults: notjunk:1;V01:K0:nW7iiygpEXE=:DjURVBGpVTLba25kbeEBV8 ddznKACOZlH8hyVTqnxDmvMmlIKyEfk1YXKgaYfcgOoFD5o1aWK6EIiadtQe/SCv+axcTfxa7 rNMsbEiiQ5cIIyV0Aq4p7PXT0VJRm8IMWedmiy16IvUeJfG9VF84sQ3dkR8tTYRiic3Soy6lQ G+xs11VPTeVdzPo06HvdqfdWVLEWlcDpHOIlAbfcsvETtTEnn+NekWH1xeT79e+r7RAUoUYyt n/ddK6LKn0Ky7AWQGx3p10lQWiHAm9C7+ToGefz5Cety4PZRMawW4pFBXuBovGa7xgR0WgdBR cqihiYLNBQd2IMyotOEvQJkJCGagDynNHgAgQjQtMpybpjFgBKNj5rCJKT/VKkUuQoLvZ8DT2 8C6FgsMdgvoVTeQ+p7hO2ZjbXp+iMIZyxrTmf44gpGSatqpSxgRbbAcIEwO+uNPulT7tRtxo9 fq3pWUlAWRkJ4+PLqj9LTtGjiPsyN1YfkGcYlXHZoAaQ9ozr91LE4UM64R0SYGEO1n4b8742G 4YkGgES0AIdnZuoqL4OjingXUQpfriApJnZPGMIBC4wFK2qTUlJ7N8RXuuw8zhdcsmDRCao7W pom/hcRX7iI18ygpYUs0SmIhQt8Xy20sJ5GTfxId50Hs1J1W5d9QKRn+W6AWnskkr0EeLGiW+ X/OfOr/1bszM65UdI2DkvTdll6wTN1Jk4IlPM6ViVBFETKCv2DbYOlfxN74eFqbA4mRc6GQ0o vmJOQTfM88jG1mKYv22cExqnGfNM+dQCffLonQhBL6tCbcfEzprBedH7A5ymIr1Y9y8al8HO X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:113203 Archived-At: On Sun, 28 May 2017 12:50:12 +0200 Marcin Borkowski wrote: > Hi all, > > I know about (current-message). However, this won't work: > > (defun get-last-message () > "Try to get the last message." > (interactive) > (with-temp-buffer > (insert (or (current-message) "")) > (clipboard-kill-ring-save (point-min) (point-max)))) > > M-x get-last-message puts the empty string into the clipboard and kill > ring. > > Apparently `current-message' is cleared before this command has a chance > to get it. This makes sense, but there is no `previous-message' command. > > Is there any way to get the last thing displayed in the echo area (from > `message' or possibly from `error', too)? This would be quite useful: > one could then paste it to a search engine to look up the internet for > some hints about the error/message. What about this: (defun get-last-message () "Try to get the last message." (interactive) (with-current-buffer "*Messages*" (goto-char (point-max)) (forward-line -1) (clipboard-kill-ring-save (line-beginning-position) (line-end-position)))) (add-hook 'post-command-hook 'get-last-message) Steve Berman