From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Magolske Newsgroups: gmane.emacs.help Subject: recentf function to manually add files to recentf-save-file Date: Tue, 18 Apr 2017 14:35:12 -0700 Message-ID: <20170418213512.GB29382@s70206.gridserver.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1492551279 16106 195.159.176.226 (18 Apr 2017 21:34:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 18 Apr 2017 21:34:39 +0000 (UTC) User-Agent: Mutt/1.5.23 (2014-03-12) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 18 23:34:35 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0alf-00045o-AP for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Apr 2017 23:34:35 +0200 Original-Received: from localhost ([::1]:44757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0all-0001Fy-1M for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Apr 2017 17:34:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0alA-0001Fh-Fu for help-gnu-emacs@gnu.org; Tue, 18 Apr 2017 17:34:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0al5-0002Fi-GQ for help-gnu-emacs@gnu.org; Tue, 18 Apr 2017 17:34:04 -0400 Original-Received: from mail6.webfaction.com ([74.55.86.74]:57759 helo=smtp.webfaction.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0al5-0002ER-Al for help-gnu-emacs@gnu.org; Tue, 18 Apr 2017 17:33:59 -0400 Original-Received: from localhost (unknown [172.56.38.75]) by smtp.webfaction.com (Postfix) with ESMTP id 5E458207B382 for ; Tue, 18 Apr 2017 21:33:57 +0000 (UTC) Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 74.55.86.74 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112807 Archived-At: 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 "") (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