unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: 56148@debbugs.gnu.org
Subject: bug#56148: [PATCH] New command recentf-open
Date: Wed, 22 Jun 2022 16:57:43 +0200	[thread overview]
Message-ID: <CADwFkmnnS7jga9Ezg7cPWCkrPydq8Fm=rCwKmX-p+gBG-M=9fQ@mail.gmail.com> (raw)

[-- 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


             reply	other threads:[~2022-06-22 14:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22 14:57 Stefan Kangas [this message]
2022-06-22 16:04 ` bug#56148: [PATCH] New command recentf-open Eli Zaretskii
2022-06-23 11:19   ` Stefan Kangas
2022-06-23 12:56     ` Eli Zaretskii
2022-06-25 11:01       ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmnnS7jga9Ezg7cPWCkrPydq8Fm=rCwKmX-p+gBG-M=9fQ@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=56148@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).