unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56148: [PATCH] New command recentf-open
@ 2022-06-22 14:57 Stefan Kangas
  2022-06-22 16:04 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Kangas @ 2022-06-22 14:57 UTC (permalink / raw)
  To: 56148

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

Severity: wishlist

In recentf-mode, I think it would be useful to provide a command to
open recent files using the minibuffer.  Please see the attached
patch.

[-- Attachment #2: 0001-New-command-recentf-open.patch --]
[-- Type: text/x-patch, Size: 1831 bytes --]

From 45b08e7b263d5804a18ccc403df2341c025b88ed Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Wed, 22 Jun 2022 16:54:40 +0200
Subject: [PATCH] New command recentf-open

* lisp/recentf.el (recentf-open): New command.
(recentf): New alias.
---
 etc/NEWS        |  5 +++++
 lisp/recentf.el | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 40658559d7..24028ac213 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1860,6 +1860,11 @@ the project by a VC project based on that VCS.
 They are shortened with 'abbreviate-file-name'.  Customize the user
 option 'recentf-menu-filter' to nil to get unabbreviated file names.
 
+---
+*** New command 'recentf-open'.
+Instead of using a menu, this command prompts for a recently opened
+file in the minibuffer, and visits it.
+
 ---
 ** The autoarg.el library is now marked obsolete.
 This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor
diff --git a/lisp/recentf.el b/lisp/recentf.el
index 1005d4855f..9e8b858bb3 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -465,6 +465,25 @@ recentf-directory-compare
         (recentf-string-lessp (file-name-nondirectory f1)
                               (file-name-nondirectory f2))
       (recentf-string-lessp d1 d2))))
+
+\f
+;;; Open files
+;;
+
+(defun recentf-open (file)
+  "Prompt for FILE in `recentf-list' and visit it.
+Enable `recentf-mode' if it isn't already."
+  (interactive
+   (list
+    (progn (unless recentf-mode (recentf-mode 1))
+           (completing-read (format-prompt "Open recent file" nil)
+                            (mapcar #'abbreviate-file-name recentf-list)
+                            nil t))))
+  (when file
+    (funcall recentf-menu-action file)))
+
+(defalias 'recentf 'recentf-open)
+
 \f
 ;;; Menu building
 ;;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-25 11:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 14:57 bug#56148: [PATCH] New command recentf-open Stefan Kangas
2022-06-22 16:04 ` Eli Zaretskii
2022-06-23 11:19   ` Stefan Kangas
2022-06-23 12:56     ` Eli Zaretskii
2022-06-25 11:01       ` Stefan Kangas

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