unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "B. T. Raven" <nihil@nihilo.net>
To: help-gnu-emacs@gnu.org
Subject: Re: More convenient editing of recentf files
Date: Sun, 15 Mar 2009 19:09:08 -0600	[thread overview]
Message-ID: <E76dnQwc-fbSBSDUnZ2dnUVZ_qTinZ2d@posted.cpinternet> (raw)
In-Reply-To: <mailman.3269.1237157595.31690.help-gnu-emacs@gnu.org>

Drew Adams wrote:
>> From: B. T. Raven Sent: Sunday, March 15, 2009 11:43 AM
>> In .emacs I have:
>> (add-to-list 'same-window-buffer-names "*Buffer List*")
>> and '(iswitchb-mode t nil (iswitchb)) in custom-set-variables
>> so I can navigate to buffers quickly with C-x b and kill 
>> selected ones with C-x C-b via D, SPC, and X keys.
> 
>> Is there a way to do something like this with recentf files?
>> Now I have to use the mousey checkbox interface:
>> menubar > Open Recent > Edit list > check ... check ... check 
>> .... move to bottom of list ... check ok
> 
> Perhaps someone else will give you an Iswitchb-specific answer for recentf file
> deletion. If not, the following might help.
> 
> If you use Icicles, you can use `Remove from Recent Files List' in menu Files >
> Icicles, or use `M-x icicle-remove-file-from-recentf-list'.
> 
> During completion, you can filter candidates with your input (e.g. substring,
> regexp, prefix), and cycle among matches. Use `C-RET' or `C-mouse-2' repeatedly
> to remove as many individual file names as you like.
> 
> Use `C-!' to remove all file names that match the current input pattern - use as
> many patterns as you like. Use `C-~' (complement) to match against all
> candidates that do *not* match some input pattern. Use `M-SPC' to combine input
> patterns (logical AND): progessive completion.
> 
> (And yes, you can use Iswitchb with Icicles.)
> 
> ----
> 
> Without Icicles, you could call, within a loop, a command that reads a single
> absolute file name using completion (letting the user quit the loop with, e.g.,
> `C-g'). A user would then complete file names to remove them from
> `recentf-list'.
> 
> (defun remove-some-recent-files ()
>   "Remove some files from the list of recently used files."
>   (interactive)
>   (while recentf-list
>     (call-interactively #'remove-a-recent-file)))
> 
> Within the loop, call `completing-read' against `recentf-list'. E.g.:
> 
> (defun remove-a-recent-file (file)
>   "Remove a file from the list of recently used files."
>   (interactive
>    (list
>     (completing-read
>      "Remove from recent files list (`C-g' when done): "
>      (mapcar #'list
>              (progn
>                (unless (boundp 'recentf-list)(require 'recentf))
>                (when (fboundp 'recentf-mode) (recentf-mode 99))
>                (unless (consp recentf-list)
>                  (error "No recently accessed files"))
>                recentf-list))
>      nil (and (fboundp 'confirm-nonexistent-file-or-buffer)
>               (confirm-nonexistent-file-or-buffer)) ; Emacs23.
>      nil 'file-name-history (car recentf-list))))
>   (setq recentf-list  (delete file recentf-list))
>   (message "`%s' removed from `recentf-list'" file))
> 
> If you know you're going to have `recentf.el' loaded and be in `recentf-mode',
> then you can skip the first part of the `progn'. If you know you have Emacs 22+,
> you can skip the `mapcar'. If you know you have Emacs 23, you can skip the
> `fboundp' for `confirm-...'.

Thanks, Drew. I called the main defun prune-recentf-list and it worked 
but with deeply nested file hierarchy, it's still a lot of typing. For 
now I'll just use:

(defalias 'rel 'recentf-edit-list)
(defalias 'rof 'recentf-open-files)
(defalias 'rsl 'recentf-save-list)

so I can avoid the mouse.

Does the code below require that Icicles be installed? It looks like it 
depends on the existence of icicle-define-command. I probably will 
install icicles someday. It looks intriguing but I need to keep things 
as close to the standard Emacs install as possible for now.

Ed

> 
> ----
> 
> FYI, a nearly identical definition suffices to define the Icicles multi-command
> (no loop needed) that lets you remove as many files as you want from the list:
> 
> (icicle-define-command icicle-remove-file-from-recentf-list
>   "Remove some files from the list of recently used files."
>   icicle-remove-from-recentf-candidate-action
>   "Remove from recent files list: "
>   (mapcar #'list
>           (progn
>             (unless (boundp 'recentf-list) (require 'recentf))
>             (when (fboundp 'recentf-mode) (recentf-mode 99))
>             (unless (consp recentf-list)
>               (error "No recently accessed files"))
>             recentf-list))
>   nil (and (fboundp 'confirm-nonexistent-file-or-buffer)
>            (confirm-nonexistent-file-or-buffer))
>   nil 'file-name-history (car recentf-list) nil
>   ((icicle-use-candidates-only-once-flag  t)))
> 
> (defun icicle-remove-from-recentf-candidate-action (file)
>   "Action function for `icicle-remove-file-from-recentf-list'."
>   (setq recentf-list  (delete file recentf-list))
>   (message "`%s' removed from `recentf-list'" file))
> 
> HTH.
> 
> 
> 


  parent reply	other threads:[~2009-03-16  1:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-15 18:42 More convenient editing of recentf files B. T. Raven
2009-03-15 19:47 ` Lennart Borgman
2009-03-15 22:53 ` Drew Adams
2009-03-15 23:02   ` Drew Adams
     [not found] ` <mailman.3262.1237146438.31690.help-gnu-emacs@gnu.org>
2009-03-15 23:01   ` B. T. Raven
     [not found] ` <mailman.3269.1237157595.31690.help-gnu-emacs@gnu.org>
2009-03-16  1:09   ` B. T. Raven [this message]
2009-03-16  3:24     ` Drew Adams

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=E76dnQwc-fbSBSDUnZ2dnUVZ_qTinZ2d@posted.cpinternet \
    --to=nihil@nihilo.net \
    --cc=help-gnu-emacs@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.
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).