all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Magolske <listmail@b79.net>
To: help-gnu-emacs@gnu.org
Subject: recentf function to manually add files to recentf-save-file
Date: Tue, 18 Apr 2017 14:35:12 -0700	[thread overview]
Message-ID: <20170418213512.GB29382@s70206.gridserver.com> (raw)

The behaviour I'd like for adding files to recentf is to have a
function bound to a key that places the current file in the buffer
into the recentf-save-file. This way recentf would keep track of
only the files that I explicitly tell it to, one keypress at a time.
In this scenario, the *only* time any file would be added to the
recentf-save-file would be when this function is run. I'd rather not
bother with running something every so often that places files that
happen to be open at that time into the recentf-save-file, figuring
out what files to exclude, synchronizing between different instances
of Emacs, etc.

Below is what I've come up with so far. The current file in buffer
is placed into the recentf-save-file whenever I press my "save" key.
Not sure if there's a better way to go about this or if I overlooked
something...any suggestions/perspectives are welcome.


;;;; elisp ;;;;

(require 'recentf)
(require 'sync-recentf)
(setq recentf-save-file (expand-file-name "recentf" user-emacs-directory)
      recentf-max-saved-items 1000)
(recentf-mode 1)

(defun jfm-add-buffer-file-to-recentf ()
  "add file in buffer to the recent list, cleanup the list (remove
duplicates, excluded files, etc.) and save to recentf-save-file"
  (interactive)
  (when (buffer-file-name)
    (recentf-add-file (buffer-file-name))
    (recentf-cleanup)
    (recentf-save-list))
  nil)

(global-set-key (kbd "<f8>")
                (lambda ()
                  (interactive)
                  (jfm-add-buffer-file-to-recentf) (save-buffer)))

(defalias 'rel 'recentf-edit-list)

;;;; end elisp ;;;;


Regards,

John

-- 
John Magolske
http://b79.net/contact



                 reply	other threads:[~2017-04-18 21:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20170418213512.GB29382@s70206.gridserver.com \
    --to=listmail@b79.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.