# Some emacs nifties

DevFeed: [Some emacs nifties](<https://devfeed.tech/articles/some-emacs-nifties-34347.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2009/08/some-emacs-nifties/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2009-08-03T13:15:00Z

Content type: tutorial

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [Emacs](<https://devfeed.tech/topics/emacs.md>), [Utility Software](<https://devfeed.tech/topics/utility.md>)

Tags: [emacs](<https://devfeed.tech/tags/emacs.md>), [functions](<https://devfeed.tech/tags/functions.md>)

## AI overview

An Emacs-focused post presenting utility functions for retrieving the previous message from the *Messages* buffer and inserting it at the current position, along with another custom function inspired by unexpected behavior.

## Source excerpt

First, here's a way to insert at current position the last message printed into the minibuffer... well not exactly, in *Messages* buffer in fact. I was tired of doing it myself after invoking, e.g., M-x emacs-version. ;; print last message ;; current-message is already lost by the time this gets called (defun dim:previous-message (&optional nth) "get last line of *Message* buffer" (with-current-buffer (get-buffer "*Messages*") (save-excursion (goto-char (point-max)) (setq nth (if nth nth 1)) (while (> nth 0) (previous-line) (setq nth (- nth 1))) (buffer-substring (line-beginning-position) (line-end-position))))) (defun dim:insert-previous-message (&optional nth) "insert last message of *Message* to current position" (interactive "p") (insert (format "%s" (dim:previous-message nth)))) (global-set-key (kbd "C-c m") 'dim:insert-previous-message) Now I stumbled accross Planet Emacsen and saw this Emacs Utility Functions post, containing a version of duplicate-current-line that I didn't like... here's mine: