From 9061e2cd8857c25d494a83ed3fa0aa9f5b9b7e61 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 26 Oct 2016 15:44:37 -0700 Subject: [emacs] add a couple of functions to open temp files One of the function is to create a temp file locally, while the second one is to create it on nest. Remove the function to find the wiki pages (they are stored in Keep and Drive now). --- emacs.d/lib/my-functions.el | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'emacs.d/lib') diff --git a/emacs.d/lib/my-functions.el b/emacs.d/lib/my-functions.el index 962a362..1281be3 100644 --- a/emacs.d/lib/my-functions.el +++ b/emacs.d/lib/my-functions.el @@ -33,17 +33,21 @@ (set-buffer-modified-p nil) (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name)))))))) -;; find a wiki page -(defun fc/find-wiki-page () - "Finds wiki page." - (interactive) - (let ((collection - (delete-dups - (append (directory-files fc/wiki-dir-location))))) - (ivy-read "wiki pages:" collection - :action (lambda (x) (find-file (concat fc/wiki-dir-location x))) - :caller 'fc/find-wiki-page))) +;; create temporary files +(defun fc/start--file (path) + "Create a file at PATH, creating any containing directories as necessary. +Visit the file after creation." + (make-directory (file-name-directory path) t) + (find-file path)) + +(defun fc/start-tmp-file (file-name) + "Create a file in /tmp for the given file name." + (interactive "sName of temporary file: ") + (fc/start--file (expand-file-name (format "/tmp/%s" file-name)))) -(global-set-key (kbd "C-c w") 'fc/find-wiki-page) +(defun fc/start-nest-tmp-file (file-name) + "Create a file in ~/tmp on nest for the give file name." + (interactive "sName of the temporary file: ") + (fc/start--file (expand-file-name (format "/nest:~/tmp/%s" file-name)))) (provide 'my-functions) -- cgit 1.4.1